-
Notifications
You must be signed in to change notification settings - Fork 728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistencty between tf_env.action_spec(action).is_compatible_with() and tf_env.step(action) #65
Comments
This line of code is involved: dim_value = tensor_shape.dimension_value(action.shape[0])
if (action.shape.ndims == 0 or
(dim_value is not None and dim_value != self.batch_size)):
raise ValueError(
'Expected actions whose major dimension is batch_size (%d), '
'but saw action with shape %s:\n %s' % (self.batch_size,
action.shape, action)) and should probably be written as: if action.shape.ndims == 0:
raise ValueError(
'Expected actions whose major dimension is batch_size (%d), '
'but saw action with shape %s:\n %s' % (self.batch_size,
action.shape, action))
dim_value = tensor_shape.dimension_value(action.shape[0])
if (dim_value is not None and dim_value != self.batch_size):
raise ValueError(
'Expected actions whose major dimension is batch_size (%d), '
'but saw action with shape %s:\n %s' % (self.batch_size,
action.shape, action)) |
So the main assumption is that action_spec and observation_spec represents the dimensions of the actions and observations without any batch or time dimension. You can take a look at the environment colab to get a better sense. |
Ok got it, many thanks! Wouldn't it make sense to have a method to validate the compatibility while taking into account the batch size? |
Yeah that makes sense, feel free to add it to utils/nest_utils.py |
Right, I'll make a PR later on. |
Hi,
As described in https://stackoverflow.com/q/55537069/4282745, I'm a bit confused by the following pieces of code:
The following piece of code works fine even through
tf_env.action_spec().is_compatible_with(action) is False
.If now, I change the shape of the action, the
action
is indeed compatible with the spec, but callingtf_env.step(action)
raises the
IndexError
below as it expects a 1-dim action array:Is there anything wrong in my code?
The text was updated successfully, but these errors were encountered: