I am probably missing something obvious but I am stuck on this:
Inside ipdb session I was able to reduce my problem to this:
ipdb> type(scores)
<class 'numpy.matrixlib.defmatrix.matrix'>
ipdb> scores.shape
(23073, 50)
ipdb> scores[np.arange(scores.shape[0]), np.zeros(scores.shape[0], dtype=np.int)] += 10
*** ValueError: array is not broadcastable to correct shape
ipdb> scores.dtype
dtype('float64')
I was not able to reproduce this problem with at simple example:
In [24]: a = np.matrix(np.zeros((6,4))
)
In [25]: a[np.arange(a.shape[0]), np.zeros(a.shape[0], dtype=np.int)] += 10
In [26]: a
Out[26]:
matrix([[ 10., 0., 0., 0.],
[ 10., 0., 0., 0.],
[ 10., 0., 0., 0.],
[ 10., 0., 0., 0.],
[ 10., 0., 0., 0.],
[ 10., 0., 0., 0.]])
In [27]: a.dtype
Out[27]: dtype('float64')
Any ideas what could be going on? What should I check?
a[:,0] += 10.