Open Johneinsteinwong opened 2 years ago
I hit the same issue. It seems like a bug as we cannot split the observation and action with BoundedTensorSpec
object.
Finally I made it works by following this example - https://github.com/tensorflow/agents/issues/255#issuecomment-809955385
hi, im trying to create a DqnAgent agent with a mask for valid/invalid actions, according to this post , i should specify a
splitter_fn
for theobservation_and_action_constraint_splitter
arg. According to the tf_agents doc, the
splitter_fn
would be like:On my mind, i thought the variable
observation
should be an array returned byenv.step(action).observation
which is an array with shape (56,) in my case (it is a flattened array with the original shape (14,4), each row are 4 feature values for each choice, there are 5-14 choices, if the choices are invalid the corresponding features will be all 0), so i wrote my splitter_fn like this:However, it returned the following error when running the above code cell:
It turns out that
print(observation)
returns aBoundedTensorSpec
object, not an array nor atf.Tensor
object. How can i create my action mask fromBoundedTensorSpec
, which doesnt even contain the array for the observation?Thanks in advance!
PS: tf_agents version is 0.12.0