[英]sklearn.manifold.TSNE TypeError: ufunc 'multiply' did not contain a loop with signature matching types (dtype('<U32'), dtype('<U32'))...)
I have run the sklearn.manifold.TSNE
example code from the sklearn documentation, but I got the error described in the questions' title.我已经运行了 sklearn 文档中的
sklearn.manifold.TSNE
示例代码,但我得到了问题标题中描述的错误。
I have already tried updating my sklearn version to the latest one (by !pip install -U scikit-learn
) (scikit-learn=1.0.1).我已经尝试将我的 sklearn 版本更新到最新版本(通过
!pip install -U scikit-learn
)(scikit-learn=1.0.1)。 However, the problem is still there.但是,问题仍然存在。
Does anyone know how to fix it?有谁知道如何修理它?
Example code:示例代码:
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
The error line happened in:错误行发生在:
X_embedded = TSNE(n_components=2, learning_rate='auto',
init='random').fit_transform(X)
Error message:错误信息:
UFuncTypeError: ufunc 'multiply' did not contain a loop with signature matching types (dtype('<U32'), dtype('<U32')) -> dtype('<U32')
Delete learning_rate='auto'
solved my problem.删除
learning_rate='auto'
解决了我的问题。
Thanks @FlaviaGiammarino comment!!感谢@FlaviaGiammarino 评论!!
The problem is with 'auto' value of learning rate.问题在于学习率的“自动”值。 Looks like a bug in this version of sklearn, cause all of string values are not acceptable for this parameter;
看起来像这个版本的 sklearn 中的一个错误,导致这个参数不能接受所有的字符串值; With float value for example
learning_rate = 100
, there would be no problem.使用浮点值,例如
learning_rate = 100
,不会有问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.