簡體   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'))...)

我已經運行了 sklearn 文檔中的sklearn.manifold.TSNE示例代碼,但我得到了問題標題中描述的錯誤。

我已經嘗試將我的 sklearn 版本更新到最新版本(通過!pip install -U scikit-learn )(scikit-learn=1.0.1)。 但是,問題仍然存在。

有誰知道如何修理它?

  • 蟒蛇= 3.7.12
  • sklearn=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 ,不會有問題。

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'),> 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’),> TypeError:ufunc&#39;add&#39;不包含簽名匹配類型為dtype(&#39;的循環 Scikit-Learn(類型錯誤:ufunc &#39;subtract&#39; 不包含簽名匹配類型 dtype(&#39; 收到錯誤:ufunc&#39;subtract&#39;不包含簽名匹配類型為dtype(&#39;的循環 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'),> 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&#39;splaly&#39;不包含帶簽名匹配類型的循環dtype(&#39;S32&#39;)dtype(&#39;S32&#39;)dtype(&#39;S32&#39;) ufunc&#39;add&#39;不包含簽名匹配類型為dtype(&#39; 類型錯誤:ufunc &#39;add&#39; 不包含具有簽名匹配類型的循環 (dtype(&#39; <U21'), dtype('<U21')) -> 數據類型(&#39;
 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM