![](/img/trans.png)
[英]ufunc 'add' did not contain a loop with signature matching types (dtype('<U32'), dtype('<U32')) -> dtype('<U32')
[英]sklearn.manifold.TSNE TypeError: ufunc 'multiply' did not contain a loop with signature matching types (dtype('<U32'), dtype('<U32'))...)
我已经运行了 sklearn 文档中的sklearn.manifold.TSNE
示例代码,但我得到了问题标题中描述的错误。
我已经尝试将我的 sklearn 版本更新到最新版本(通过!pip install -U scikit-learn
)(scikit-learn=1.0.1)。 但是,问题仍然存在。
有谁知道如何修理它?
示例代码:
import numpy as np
from sklearn.manifold import TSNE
X = np.array([[0, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 1]])
X_embedded = TSNE(n_components=2, learning_rate='auto',
init='random').fit_transform(X)
X_embedded.shape
错误行发生在:
X_embedded = TSNE(n_components=2, learning_rate='auto',
init='random').fit_transform(X)
错误信息:
UFuncTypeError: ufunc 'multiply' did not contain a loop with signature matching types (dtype('<U32'), dtype('<U32')) -> dtype('<U32')
删除learning_rate='auto'
解决了我的问题。
感谢@FlaviaGiammarino 评论!!
问题在于学习率的“自动”值。 看起来像这个版本的 sklearn 中的一个错误,导致这个参数不能接受所有的字符串值; 使用浮点值,例如learning_rate = 100
,不会有问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.