简体   繁体   English

sklearn.manifold.TSNE TypeError:ufunc'multiply'不包含签名匹配类型的循环(dtype('

[英]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?有谁知道如何修理它?

  • python = 3.7.12蟒蛇= 3.7.12
  • sklearn= 1.0.1 sklearn=1.0.1

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 ,不会有问题。

ufunc 'add' 不包含带有签名匹配类型的循环 (dtype(' <u32'), dtype('<u32')) -> dtype(' <u32')< div><div id="text_translate"><p> 我正在尝试运行此脚本,但它显示生成的错误:</p><pre> UFuncTypeError: ufunc 'add' did not contain a loop with signature matching types (dtype('<U32'), dtype('<U32')) -> dtype('<U32')</pre><p> 这是我试图运行的下面的代码:</p><pre> if __name__ == '__main__': app = Nominatim(user_agent="test_solar") loc_raw = app.geocode('Postintaival 7, 00230 Helsinki, Finland').raw latitude = loc_raw['lat'] longitude = loc_raw['lon'] altitude = get_elevation(latitude, longitude) location_object = Location(latitude, longitude, 'Europe/Helsinki', altitude, 'relex_solutions') weather = pvlib.iotools.get_pvgis_tmy(latitude, longitude, map_variables=True)[0] times = weather.index solpos = location_object.get_solarposition(times) clearsky_values = location_object.get_clearsky(times, model='ineichen', solar_position=solpos, dni_extra=None)</pre> </div></u32')<></u32'),> - ufunc 'add' did not contain a loop with signature matching types (dtype('<U32'), dtype('<U32')) -> dtype('<U32')

UFuncTypeError:ufunc 'clip' 不包含具有签名匹配类型的循环(dtype(' <u32’), dtype(‘<u32’), dtype(‘<u32’)) -> dtype(' <u32’)< div><div id="text_translate"><p> 我使用 Deep Pavlov 框架与 Bert 分类器一起工作,只是因为我需要预测人员的语言是俄语。 基本上,我正在尝试解决多类分类问题。 根据 Deep Pavlov,我们可以轻松地更改配置文件上的一些配置。 我拿了这个配置文件<a href="https://github.com/deepmipt/DeepPavlov/blob/master/deeppavlov/configs/classifiers/rusentiment_convers_bert.json" rel="nofollow noreferrer">https://github.com/deepmipt/DeepPavlov/blob/master/deeppavlov/configs/classifiers/rusentiment_convers_bert.json</a>并训练它,结果我花了大约 13 个小时才完成它我的 model 过拟合。</p><p> 我做了一些改变,尤其是这些:</p><pre> "weight_decay_rate": 0.001, "learning_rate_drop_patience": 1, "learning_rate_drop_div": 2.0, "load_before_drop": True, "min_learning_rate": 1e-03, "attention_probs_keep_prob": 0.5, "hidden_keep_prob": 0.5,</pre><p> 另外,我增加了批量大小,之前是 16:</p><pre> "batch_size": 32</pre><p> 并添加了一些指标:</p><pre> "log_loss", "matthews_correlation",</pre><p> 还将validation_patience更改为1并添加了tensorboard func</p><pre> "validation_patience": 1, "tensorboard_log_dir": "logs/",</pre><p> 就是这样。 这些是我对 model 所做的所有更改,当我尝试训练我的 model 时,它给了我以下错误:</p><pre> UFuncTypeError Traceback (most recent call last) /usr/local/lib/python3.7/dist-packages/numpy/core/fromnumeric.py in _wrapfunc(obj, method, *args, **kwds) 60 try: ---&gt; 61 return bound(*args, **kwds) 62 except TypeError: 15 frames UFuncTypeError: ufunc 'clip' did not contain a loop with signature matching types (dtype('&lt;U32'), dtype('&lt;U32'), dtype('&lt;U32')) -&gt; dtype('&lt;U32') During handling of the above exception, another exception occurred: UFuncTypeError Traceback (most recent call last) &lt;__array_function__ internals&gt; in clip(*args, **kwargs) /usr/local/lib/python3.7/dist-packages/numpy/core/_methods.py in _clip_dep_invoke_with_casting(ufunc, out, casting, *args, **kwargs) 83 # try to deal with broken casting rules 84 try: ---&gt; 85 return ufunc(*args, out=out, **kwargs) 86 except _exceptions._UFuncOutputCastingError as e: 87 # Numpy 1.17.0, 2019-02-24 UFuncTypeError: ufunc 'clip' did not contain a loop with signature matching types (dtype('&lt;U32'), dtype('&lt;U32'), dtype('&lt;U32')) -&gt; dtype('&lt;U32')</pre><p> 起初,我认为它与数据集有关,但是,我没有更改我的数据集,并且在我第一次训练这个 model 时它已经运行。 </p></div></u32’)<></u32’),> - UFuncTypeError: ufunc ‘clip’ did not contain a loop with signature matching types (dtype(‘<U32’), dtype(‘<U32’), dtype(‘<U32’)) -> dtype(‘<U32’)

UFuncTypeError:ufunc 'matmul' 不包含具有签名匹配类型的循环(dtype(' <u32'), dtype('<u32')) -> dtype(' <u32') - streamlit< div><div id="text_translate"><pre> #Linear Regression Model @st.cache(allow_output_mutation=True) def linearRegression(X_train, X_test, y_train, y_test): model = LinearRegression() model.fit(X_train,y_train) score = model.score(X_test, y_test)*100 return score, model</pre><hr><pre> #User input for the model def user_input(): bedrooms = st.slider("Bedrooms: ", 1,15) bathrooms = st.text_input("Bathrooms: ") sqft_living = st.text_input("Square Feet: ") sqft_lot = st.text_input("Lot Size: ") floors = st.text_input("Number Of Floors: ") waterfront = st.text_input("Waterfront? For Yes type '1', For No type '0': ") view = st.slider("View (A higher score will mean a better view): ", 0,4) condition = st.slider("House Condition (A higher score will mean a better condition): ", 1,5) yr_built = st.text_input("Year Built: ") yr_reno = st.text_input("A Renovated Property? For Yes type '1', For No type '0': ") zipcode = st.text_input("Zipcode (5 digit): ") year_sold = st.text_input("Year Sold: ") month_sold = st.slider("Month Sold: ", 1,12) user_input_prediction = np.array([bedrooms,bathrooms,sqft_living, sqft_lot,floors,waterfront,view,condition,yr_built,yr_reno,zipcode,year_sold,month_sold]).reshape(1,-1) return(user_input_prediction)</pre><hr><pre> #Main function if(st.checkbox("Start a Search")): user_input_prediction = user_input() st.write('error1') pred = model.predict(user_input_prediction) st.write('error2') if(st.button("Submit")): st.text("success")</pre><p> 我正在使用 Streamlit 构建一个接受用户输入的 ML model。 在我的主要 function 中,它返回错误UFuncTypeError: ufunc 'matmul' did not contain a loop with signature matching types (dtype('&lt;U32'), dtype('&lt;U32')) -&gt; dtype('&lt;U32') and trace返回pred = model.predict(user_input_prediction)主 function 将打印出 error1 但不会打印 error2</p></div></u32')></u32'),> - UFuncTypeError: ufunc 'matmul' did not contain a loop with signature matching types (dtype('<U32'), dtype('<U32')) -> dtype('<U32') - Streamlit

TypeError: ufunc 'add' 不包含签名匹配类型 dtype(' <u1') dtype('<u1') dtype('<u1')< div><div id="text_translate"><p> 我是 Python 用户的初学者。 当我尝试在下面编写代码时发生错误</p><pre>import numpy as np np.array(['a', 'b', 'c']) + np.array(['d','e', 'f'])</pre><pre> TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('&lt;U1') dtype('&lt;U1') dtype('&lt;U1')</pre><p> 所以我尝试设置dtype = '&lt;U1' ,但它没有用</p><pre>import numpy as np np.array(['a', 'b', 'c'], dtype='&lt;U1') + np.array(['d','e', 'f'], dtype='&lt;U1')</pre><p> 如何无错误地连接那些 np.arrays ?</p></div></u1')> - TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('<U1') dtype('<U1') dtype('<U1')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ufunc 'add' 不包含带有签名匹配类型的循环 (dtype(' <u32'), dtype('<u32')) -> dtype(' <u32')< div><div id="text_translate"><p> 我正在尝试运行此脚本,但它显示生成的错误:</p><pre> UFuncTypeError: ufunc 'add' did not contain a loop with signature matching types (dtype('<U32'), dtype('<U32')) -> dtype('<U32')</pre><p> 这是我试图运行的下面的代码:</p><pre> if __name__ == '__main__': app = Nominatim(user_agent="test_solar") loc_raw = app.geocode('Postintaival 7, 00230 Helsinki, Finland').raw latitude = loc_raw['lat'] longitude = loc_raw['lon'] altitude = get_elevation(latitude, longitude) location_object = Location(latitude, longitude, 'Europe/Helsinki', altitude, 'relex_solutions') weather = pvlib.iotools.get_pvgis_tmy(latitude, longitude, map_variables=True)[0] times = weather.index solpos = location_object.get_solarposition(times) clearsky_values = location_object.get_clearsky(times, model='ineichen', solar_position=solpos, dni_extra=None)</pre> </div></u32')<></u32'),> - ufunc 'add' did not contain a loop with signature matching types (dtype('<U32'), dtype('<U32')) -> dtype('<U32') UFuncTypeError:ufunc 'clip' 不包含具有签名匹配类型的循环(dtype(' <u32’), dtype(‘<u32’), dtype(‘<u32’)) -> dtype(' <u32’)< div><div id="text_translate"><p> 我使用 Deep Pavlov 框架与 Bert 分类器一起工作,只是因为我需要预测人员的语言是俄语。 基本上,我正在尝试解决多类分类问题。 根据 Deep Pavlov,我们可以轻松地更改配置文件上的一些配置。 我拿了这个配置文件<a href="https://github.com/deepmipt/DeepPavlov/blob/master/deeppavlov/configs/classifiers/rusentiment_convers_bert.json" rel="nofollow noreferrer">https://github.com/deepmipt/DeepPavlov/blob/master/deeppavlov/configs/classifiers/rusentiment_convers_bert.json</a>并训练它,结果我花了大约 13 个小时才完成它我的 model 过拟合。</p><p> 我做了一些改变,尤其是这些:</p><pre> "weight_decay_rate": 0.001, "learning_rate_drop_patience": 1, "learning_rate_drop_div": 2.0, "load_before_drop": True, "min_learning_rate": 1e-03, "attention_probs_keep_prob": 0.5, "hidden_keep_prob": 0.5,</pre><p> 另外,我增加了批量大小,之前是 16:</p><pre> "batch_size": 32</pre><p> 并添加了一些指标:</p><pre> "log_loss", "matthews_correlation",</pre><p> 还将validation_patience更改为1并添加了tensorboard func</p><pre> "validation_patience": 1, "tensorboard_log_dir": "logs/",</pre><p> 就是这样。 这些是我对 model 所做的所有更改,当我尝试训练我的 model 时,它给了我以下错误:</p><pre> UFuncTypeError Traceback (most recent call last) /usr/local/lib/python3.7/dist-packages/numpy/core/fromnumeric.py in _wrapfunc(obj, method, *args, **kwds) 60 try: ---&gt; 61 return bound(*args, **kwds) 62 except TypeError: 15 frames UFuncTypeError: ufunc 'clip' did not contain a loop with signature matching types (dtype('&lt;U32'), dtype('&lt;U32'), dtype('&lt;U32')) -&gt; dtype('&lt;U32') During handling of the above exception, another exception occurred: UFuncTypeError Traceback (most recent call last) &lt;__array_function__ internals&gt; in clip(*args, **kwargs) /usr/local/lib/python3.7/dist-packages/numpy/core/_methods.py in _clip_dep_invoke_with_casting(ufunc, out, casting, *args, **kwargs) 83 # try to deal with broken casting rules 84 try: ---&gt; 85 return ufunc(*args, out=out, **kwargs) 86 except _exceptions._UFuncOutputCastingError as e: 87 # Numpy 1.17.0, 2019-02-24 UFuncTypeError: ufunc 'clip' did not contain a loop with signature matching types (dtype('&lt;U32'), dtype('&lt;U32'), dtype('&lt;U32')) -&gt; dtype('&lt;U32')</pre><p> 起初,我认为它与数据集有关,但是,我没有更改我的数据集,并且在我第一次训练这个 model 时它已经运行。 </p></div></u32’)<></u32’),> - UFuncTypeError: ufunc ‘clip’ did not contain a loop with signature matching types (dtype(‘<U32’), dtype(‘<U32’), dtype(‘<U32’)) -> dtype(‘<U32’) TypeError:ufunc&#39;add&#39;不包含签名匹配类型为dtype(&#39;的循环 - TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('<U32') dtype('<U32') dtype('<U32') Scikit-Learn(类型错误:ufunc &#39;subtract&#39; 不包含签名匹配类型 dtype(&#39; - Scikit-Learn (TypeError: ufunc 'subtract' did not contain a loop with signature matching types dtype('<U32') dtype('<U32') dtype('<U32')) 收到错误:ufunc&#39;subtract&#39;不包含签名匹配类型为dtype(&#39;的循环 - Getting error: ufunc 'subtract' did not contain a loop with signature matching types dtype('<U32') dtype('<U32') dtype('<U32') UFuncTypeError:ufunc 'matmul' 不包含具有签名匹配类型的循环(dtype(' <u32'), dtype('<u32')) -> dtype(' <u32') - streamlit< div><div id="text_translate"><pre> #Linear Regression Model @st.cache(allow_output_mutation=True) def linearRegression(X_train, X_test, y_train, y_test): model = LinearRegression() model.fit(X_train,y_train) score = model.score(X_test, y_test)*100 return score, model</pre><hr><pre> #User input for the model def user_input(): bedrooms = st.slider("Bedrooms: ", 1,15) bathrooms = st.text_input("Bathrooms: ") sqft_living = st.text_input("Square Feet: ") sqft_lot = st.text_input("Lot Size: ") floors = st.text_input("Number Of Floors: ") waterfront = st.text_input("Waterfront? For Yes type '1', For No type '0': ") view = st.slider("View (A higher score will mean a better view): ", 0,4) condition = st.slider("House Condition (A higher score will mean a better condition): ", 1,5) yr_built = st.text_input("Year Built: ") yr_reno = st.text_input("A Renovated Property? For Yes type '1', For No type '0': ") zipcode = st.text_input("Zipcode (5 digit): ") year_sold = st.text_input("Year Sold: ") month_sold = st.slider("Month Sold: ", 1,12) user_input_prediction = np.array([bedrooms,bathrooms,sqft_living, sqft_lot,floors,waterfront,view,condition,yr_built,yr_reno,zipcode,year_sold,month_sold]).reshape(1,-1) return(user_input_prediction)</pre><hr><pre> #Main function if(st.checkbox("Start a Search")): user_input_prediction = user_input() st.write('error1') pred = model.predict(user_input_prediction) st.write('error2') if(st.button("Submit")): st.text("success")</pre><p> 我正在使用 Streamlit 构建一个接受用户输入的 ML model。 在我的主要 function 中,它返回错误UFuncTypeError: ufunc 'matmul' did not contain a loop with signature matching types (dtype('&lt;U32'), dtype('&lt;U32')) -&gt; dtype('&lt;U32') and trace返回pred = model.predict(user_input_prediction)主 function 将打印出 error1 但不会打印 error2</p></div></u32')></u32'),> - UFuncTypeError: ufunc 'matmul' did not contain a loop with signature matching types (dtype('<U32'), dtype('<U32')) -> dtype('<U32') - Streamlit TypeError: ufunc 'add' 不包含签名匹配类型 dtype(' <u1') dtype('<u1') dtype('<u1')< div><div id="text_translate"><p> 我是 Python 用户的初学者。 当我尝试在下面编写代码时发生错误</p><pre>import numpy as np np.array(['a', 'b', 'c']) + np.array(['d','e', 'f'])</pre><pre> TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('&lt;U1') dtype('&lt;U1') dtype('&lt;U1')</pre><p> 所以我尝试设置dtype = '&lt;U1' ,但它没有用</p><pre>import numpy as np np.array(['a', 'b', 'c'], dtype='&lt;U1') + np.array(['d','e', 'f'], dtype='&lt;U1')</pre><p> 如何无错误地连接那些 np.arrays ?</p></div></u1')> - TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('<U1') dtype('<U1') dtype('<U1') TypeError:ufunc&#39;splaly&#39;不包含带签名匹配类型的循环dtype(&#39;S32&#39;)dtype(&#39;S32&#39;)dtype(&#39;S32&#39;) - TypeError: ufunc 'multiply' did not contain a loop with signature matching types dtype('S32') dtype('S32') dtype('S32') ufunc&#39;add&#39;不包含签名匹配类型为dtype(&#39; - ufunc 'add' did not contain a loop with signature matching types dtype('<U23') dtype('<U23') dtype('<U23') 类型错误:ufunc &#39;add&#39; 不包含具有签名匹配类型的循环 (dtype(&#39; <U21'), dtype('<U21')) -> 数据类型(&#39; - TypeError: ufunc 'add' did not contain a loop with signature matching types (dtype('<U21'), dtype('<U21')) -> dtype('<U21')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM