VinF / deer

DEEp Reinforcement learning framework
Other
485 stars 126 forks source link

Small change of type to allow for multi dimensional actions with DDPG #79

Closed gregoire-moreau closed 4 years ago

gregoire-moreau commented 4 years ago

actions_val is a numpy array of objects where each object is a numpy array containing the action taken at a certain step of training with a float corresponding to each dimension of the action space. The shape of actions_val is thus (_batchsize, ). For multidimensional action spaces, this triggers an error inside Keras as the training algorithm expects an array of shape (_batchsize, _ndim) where _ndim is the dimensionality of the action space.

To fix this, we can transform _actionsval to a list, and transform that list to a numpy array. Numpy will automatically detect that each element of the list is a numpy array of _ndim floats, and will therefore create an array of shape (_batchsize, _ndim).

VinF commented 4 years ago

Thanks! Can you also modify the comment here to reflect the shape of actions_val in the case of both unidimensional and multidimensional action spaces?

Note that to simplify things, I'm wondering whether actions_val should not be directly given as an array of shape (batch_size, n_dim), but this would require refactoring some parts of the code.

gregoire-moreau commented 4 years ago

I just modified the comment to give a better description of _actionsval.