簡體   English   中英

Transformers 類從何而來?

[英]Where does class Transformers come from?

全部顯示使用這個導入

from sklearn.pipeline import Pipeline, FeatureUnion
from Transformers import TextTransformer

當我運行它

ModuleNotFoundError Traceback (most recent call last) <ipython-input-6-1f277e1659bb> in <module>() 1 from sklearn.pipeline import Pipeline, FeatureUnion ----> 2 from Transformers import TextTransformer ModuleNotFoundError: No module named 'Transformers

谷歌搜索只會讓我找到我已經發布的鏈接。
Transformers從何而來?


import sklearn
import sys
print(sklearn.__version__)
print(sys.version)

0.18.1
3.6.0 |Anaconda 4.3.1 (x86_64)| (default, Dec 23 2016, 13:19:00) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]

關於什么

pip install transformers

錯誤消息ModuleNotFoundError: No module named 'Transformers是因為最有可能沒有安裝轉換器。

從您提供的第二個鏈接來看,它似乎是一個名為Transformers.py的用戶定義文件,其中包含類TextTransformer

是的,我很確定它是一些包含變壓器的自定義文件,它們很可能繼承自TransformerMixin ( http://scikit-learn.org/stable/modules/generated/sklearn.base.TransformerMixin.html )。

如鏈接的問題所示,這允許在管道中包含自定義數據轉換。 對於介紹,我推薦這篇很棒的博客文章,其中還顯示了自定義轉換器:http: //zacstewart.com/2014/08/05/pipelines-of-featureunions-of-pipelines.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM