![](/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.