ValueError: shapes (1,1568) and (1,1568) not aligned: 1568 (dim 1) != 1 (dim 0)
問題:
想把a=1 * 1568,b=1 * 1568用python做內積,但是報錯:
ValueError: shapes (1,1568) and (1,1568) not aligned: 1568 (dim 1) != 1 (dim 0)
解決:把b向量轉換為1568*1的列向量。
舉例
a = np.arange(3).reshape(1,3)
b = np.arange(3,6).reshape(1,3)
得到:
如果你在這時候對a, b做內積,則會報如下:
當我們對b做一個變換:
>>> c = b.reshape(3,1) >>> c array([[3], [4], [5]])
再做內積
np.dot(a,c)
得到:
>>> np.dot(a,c)
array([[14]])
相關推薦
ValueError: shapes (1,1568) and (1,1568) not aligned: 1568 (dim 1) != 1 (dim 0)
技術標籤:pythonpython 問題: 想把a=1 * 1568,b=1 * 1568用python做內積,但是報錯: ValueError: shapes (1,1568) and (1,1568) not aligned: 1568 (dim 1) != 1 (dim 0)
解決大於5.7版本mysql的分組報錯Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated
原因: MySQL 5.7.5和up實現了對功能依賴的檢測。如果啟用了only_full_group_by SQL模式(在預設情況下是這樣),那麼MySQL就會拒絕選擇列表、條件或順序列表引用的查詢,這些查詢將引用組中未命名的非聚合列,而不
mysql遇見Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre
技術標籤:work 同一個程式,執行在dev和prod不同環境裡,同一個介面竟然一個正常,一個報錯500,但是資料庫的資料都一樣的,搜了很久,終於在一篇文章裡面解決了: 問題出現的原因: MySQL 5.7.5及以上功能依賴
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregate
在mysql 5.7使用group by時會出現錯誤,首先表資訊如下: select name from student group by classid;會出現下列錯誤
tomcat啟動報are only available on JDK 1.5 and higher錯誤
專案中用的是spring低版本(2.5.6),今天用jre 8測試了一下,發現錯誤: Unexpected exception parsing XML document from
Codeforces Round #485 (Div. 1) C - AND Graph
用了很神奇的辦法,對於每一個數,取反,暴力找它所有子集,如果dfs到的數字又是我們輸入的數字,就繼續取反暴力找子集
git did not exit cleanly (exit code 1) 的解決辦法
技術標籤:gitgit git did not exit cleanly的解決辦法 git did not exit cleanly (exit code 1) 的解決辦法
Android Build output:w: -Xcoroutines has no effect: coroutines are enabled anyway in 1.3 and beyond
技術標籤:kotlinAndroidandroid移動開發android studio程式語言 簡單記錄Android開發遇到的小坑-Kotlin系列
思維訓練——CF1304E 1-Trees and Queries
題目連結:https://www.luogu.com.cn/problem/CF1304E 這道題稍微想了一下就有思路了。 讓我們先來簡化一下問題,如果沒有加邊,僅僅是詢問的話,那麼該怎麼做呢。
Codeforces Round #562 (Div. 1) C. And Reachability
https://codeforces.com/contest/1168/problem/C 考慮\\(dp\\),\\(dp[i][j]\\)表示從i開始最先到達的第j位為1的位置
CF1304E 1-Trees and Queries
題目連結 對樹的路徑進行操作,不難想到樹的路徑是唯一的,離不開LCA 新增一條新邊後,答案有兩種可能,一是走原樹上路徑,二是通過這條邊走到
1. Vectors and Linear Combinations
Vectors and Linear Combinations Vectors We have n separate numbers $v_1、v_2、v_3,...,v_n$,that produces a n-dimensional vector $v$,and $v$ is represented by an arrow.
寫出下面各邏輯表示式的值。設a=3,b=4,c=5 (1)a + b > c && b == c (2)a || b + c && b - c (3)!(a > b) && !c || 1 (4)!(x = a) && (y = b) && 0 (5)!(a + b) + c - 1 &
寫出下面各邏輯表示式的值。設a=3,b=4,c=5。 (1)a + b > c && b == c (2)a || b + c && b - c
存款利息的計算。有1000元,想存5年,可按以下5種辦法存(1)一次存5年期 (2)先存2年期,到期後將本息再存3年期 (3)先存3年期,到期後將本息再存2年期 (4)存1年期,到期後將本息再存1年期,連續存5次 (5)存活期存款,活期利息每一季度結算一次
存款利息的計算。有1000元,想存5年,可按以下5種辦法存: (1)一次存5年期
1<2<3=true,3>2>1=false,[] == ![]為true,{} == !{}為false
技術標籤:web前端javascript前端 1<2<3輸出結果為true 3>2>1輸出結果為false
《原神攻略》1.2百貨奇貨第三天怎麼玩 1.2百貨奇貨第三天玩法分享
原神1.2百貨奇貨第三天怎麼玩?近期遊戲中的百貨奇貨活動已經正式開啟了,今天小編給大家帶來原神1.2百貨奇貨第三天玩法分享,快來看一下吧。
No Hibernate Session bound to thread, and configuration does not allow creation of non-transactiona
技術標籤:grailshibernatehibernate sessionjava Exception in thread “Thread-61” org.hibernate.HibernateException:No Hibernate Session bound to thread, and configuration does not allow creation of
《原神攻略》1.3福至五彩第三天怎麼玩 1.3福至五彩紅色生物介紹
原神1.3福至五彩第三天怎麼玩?近期福至五彩活動已經開啟第三天了,很多小夥伴還不清楚今天怎麼玩吧,今天小編給大家帶來原神1.3福至五彩紅色生物介紹,快來看一下吧。
隨身 1 條就夠了:羅馬仕 3 合 1 資料線 10.9 元新低
羅馬仕旗艦店今日開啟春節大促:天貓羅馬仕 一拖三通用資料線一線三通,防纏繞9.9元直達連結一乖很建議買0.6m款,短一點方便很多。天貓羅馬仕 通用充電器1A、2.1A可選券後11.9元領5元券
《原神攻略》1.4杯裝之詩祈願什麼時候開啟 1.4溫迪復刻時間介紹
原神1.4杯裝之詩祈願什麼時候開啟?近期官方正式公佈了溫迪復刻的時間,今天小編給大家帶來原神1.4溫迪復刻時間介紹,快來看一下吧。