np.sum次元降次元問題:cs 231 n assignment 2エラー「ValueError:non-broadcastable output operand」
エラー:
理由:
fc_net.py、TwoLayerNetクラス:
layersではpy、affine_backward関数ではnpを用いる.sumの場合、keepdims=Trueを指定せずに次元ダウンの問題に直面します.
python broadcastメソッドでは次元が一致する必要があります
その後の解決策は明らかになったparams['b 1']はdbの次元と一致すればよい.
ここでnpについて.sum次元の問題、参照:https://blog.csdn.net/m0_37390405/article/details/79175273
ValueError: non-broadcastable output operand with shape (100,1) doesn't match the broadcast shape (100,100)
理由:
fc_net.py、TwoLayerNetクラス:
self.params['b1'] = np.zeros(hidden_dim) b1
self.params['b1'] = np.zeros((hidden_dim,1)) b1
layersではpy、affine_backward関数ではnpを用いる.sumの場合、keepdims=Trueを指定せずに次元ダウンの問題に直面します.
db=np.sum(dout,axis=0) db ,db
db=np.sum(dout,axis=0,keepdims=True) db
python broadcastメソッドでは次元が一致する必要があります
その後の解決策は明らかになったparams['b 1']はdbの次元と一致すればよい.
ここでnpについて.sum次元の問題、参照:https://blog.csdn.net/m0_37390405/article/details/79175273