I have a strange situation which I do not understand. I wand to use an array as indices.
batch_index = np.arange(min(mb_size,len(D)), dtype=np.int32)
Q_target[batch_index, actions] = rewards + gamma*np.max(Q_next, axis=1)*dones
But when I run this I get an error:
IndexError: arrays used as indices must be of integer (or boolean) type
It appears to be an array of objects:
In: actions
Out: array([2, 2, 2, 2], dtype=object)
The same in variable explorer:
Type: Array of object Value: ndarray object of numpy module
In the same time:
In:type(actions[0])
Out: numpy.int64
I know that I can use:
actions = np.array(actions, dtype=np.int32)
But I do not understand why do I have to do it.
P.S. here is how I get actions
D = deque()
D.append((state, action, reward, state_new, done))
#type(action) == int64
minibatch = np.array(random.sample(D, min(mb_size,len(D))))
actions = minibatch[:,1]