ValueError: operands could not be broadcast together with shapes (2,) (1640,)已解決
在量化交易資料處理中遇到一個問題
違反了ufunc的廣播機制(有關廣播概念,單開一篇詳細介紹:傳送蟲洞)
廣播機制如下:
當我們使用ufunc函式對兩個陣列進行計算時,ufunc函式會對這兩個陣列的對應元素進行計算,因此它要求這兩個陣列有相同的大小(shape相同)。如果兩個陣列的shape不同的話,會進行如下的廣播(broadcasting)處理:
- 讓所有輸入陣列都向其中shape最長的陣列看齊,shape中不足的部分都通過在前面加1補齊
- 輸出陣列的shape是輸入陣列shape的各個軸上的最大值
- 如果輸入陣列的某個軸和輸出陣列的對應軸的長度相同或者其長度為1時,這個陣列能夠用來計算,否則出錯
- 當輸入陣列的某個軸的長度為1時,沿著此軸運算時都用此軸上的第一組值
此例中的錯誤來自75行,0.903寫錯了一個標點,寫成0,903導致,語法提醒的~以後一定要注意。
既然問題出在75行,但是為什麼提示的是77行,因為在計算機眼睛裡75行沒有錯,語法上並沒錯,只是不符合我們設定的邏輯而已。這裡便引出“ , ”(逗號)這個符號的意義,比較複雜,我們專門開一篇來講(傳送蟲洞)。
-
參考資料
相關推薦
ValueError: operands could not be broadcast together with shapes (2,) (1640,)已解決
在量化交易資料處理中遇到一個問題 違反了ufunc的廣播機制(有關廣播概念,單開一篇詳細介紹:傳送蟲洞) 廣播機制如下: 當我們使用ufunc函式對兩個陣列進行計算時,ufunc函式會對這兩個陣列的對應元素進行計算,因此它要求這兩個陣列有相同的大小(shape
Faster RCNN訓練出現問題:ValueError: operands could not be broadcast together with shapes
ss = 0.0154733 (* 1 = 0.0154733 loss) I1017 02:21:18.817603 16224 solver.cpp:245] Train net output #3: rpn_loss_bbox = 0.101269 (* 1
python問題:ValueError: operands could not be broadcast together with shapes (100,3) (3,1)
原文連結:http://www.mamicode.com/info-detail-1072145.html 背景:dataMatrix是(100,3)的列表,labelMat是(1,100)的列表,weights是(3,1)的陣列,屬性如下程式碼所示: >>
Python-Numpy: operands could not be broadcast together with shapes
BUG樣式: ValueError: operands could not be broadcast together with shapes (353,) (355,) 舉個栗子: import numpy numpy_a=numpy.array([1, 2, 3, 4,
WARNING: The host 'WeiLei' could not be looked up with resolveip.
[[email protected] data]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/WARNING:
Connection could not be established with host smtp.163.com
ssl 阿裏雲 加密 str col 本地 服務 ould nbsp laravel阿裏雲屏蔽25,無法發送郵件的解決方案 本地測試郵件可以發送成功,部署在阿裏雲上,在安全組中配置了25端口的出入後還是不行。 也就是加入了SSL驗證,測試,問題迎刃而解! 阿裏雲服務器封禁
composer在update時提示file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages: error:1407742E:SSL routines:SSL23_GET_SERVER
在開發的時候,需要把依賴的服務更新到最新,然後 手動composer update一下,提示如下: 1 failed) Update failed (The "e "https://api.github.com/repos/illuminate/validation/zipba
Connection could not be established with host smtp.163.com 阿星小棧
laravel阿里雲屏蔽25,無法傳送郵件的解決方案 本地測試郵件可以傳送成功,但是部署在阿里雲伺服器上之後,並且在安全組中配置了25埠的出入後還是不行。 原因是: 阿里雲伺服器封禁了25 解決辦法 埠號port 改成 465 加密方式&nb
Eclipse:Some sites could not be found. See the error log for more detail.解決的方法
span pda more .net sof 分析 clas csdn war 今天遇到了一個奇葩的問題。我把我的sdk tools的版本號升級到23後。我在eclipse中嘗試升級ADT,發現了這麽一個問題,以下分析下原因: 當我在eclipse中選擇Help--&g
多個jdk 變更 引起 tomcat插件 啟動不了 The JRE could not be found.Edit the server and change the JRE location.
變更 runtime win jdk nts nvi bsp 選擇 ould The JRE could not be found.Edit the server and change the JRE location. 在Windows->Preference
初次使用git就遭遇不測,提示沒有這個服務連接和需要配置git的一個http參數 NO network connection,SSl host could not be verified ...
連接 ... 客戶 用戶 eclispe img net ren src 第一次使用git 拉取服務上的項目到本地,結果,在拿到訪問的url地址後,輸入用戶名密碼,失敗了。 --eclispe 4.5.3 繼承了git客戶端插件的版本 -----
myeclipse編譯彈框:The builder launch configuration could not be found
lips def ast ssi src 選中項 tail .net 啟動 myEclipse 每次編譯時報 "The builder launch configuration could not be found" 的彈框:不影響項目編譯啟動,但是彈框挺煩人,從網上看到解
XCode 或者ITune 添加賬號時,提示:This action could not be completed. 或者 Access Privileges
net clas cti people led acc missing rec itunes 當遇到This action could not be completed 或者 You do not have enough access privileges for this
MyEclipse中Save could not be completed
不支持 def sun col 技術分享 100% 編譯 could not data- 在MyEclipse下編程時,保存的時候,假設出現例如以下圖所看到的錯誤: 首先說明MyEclipse的默認編譯語言是"ISO-8859-1&quo
[Nagios] Error: Template 'timman' specified in contact definition could not be not found (c
ati 內容 pat ace data rcu notify track ems Check nagios配置文件報錯例如以下:[[email protected]/* */ etc]$ /usr/local/nagios/bin/nagios -v /us
MySQL server PID file could not be found!
blog 做的 所有 寫的權限 如果 rate data 重啟 一個個 重啟mysql提示MySQL server PID file could not be found! Starting MySQL...The server quit without updating
mac上 go-delve 安裝出現The specified item could not be found in the keychain 解決方法
mon pen 方法 rar spec hub 錯誤 sys lib 安裝go語言的編譯環境,在安裝到 delve時候出現如下錯誤: If reporting this issue please do so at (not Homebrew/brew or Hom
require sqlite3時報The specified module could not be found.錯誤
平臺 git module 時報 target hub walk require 編譯 http://dependencywalker.com/ 在這個站點下載對應平臺的Dependency Walker,打開你自己編譯好的.node文件(sqlite3\lib\bindi
NIOS II ecliplse中出現Symbol 'XX_BASE' COULD NOT BE RESOLVED解決
編寫程序 pos ould blog rate pan cli 解決辦法 gpo NIOS II ecliplse中出現Symbol ‘XX_BASE‘ COULD NOT BE RESOLVED解決 在nios II中,明明system.h中定義了#define xxx_
eclipse啟動報錯the catalog could not be loaded please ensure that you have network access and if needed have configured your network proxy
實例 等待 ces .cn access 分享圖片 clas 安裝包 nan 搜索關鍵詞不對在網上查了一圈沒找到合適的解決辦法 去看報錯的日誌文件 然並卵。不過下面有個config.ini,想著以前能用現在不能用,肯定是配置問題,打開該文件 轉載請註明出處http