Open mjlbach opened 4 years ago
For now the simplest solution is probably to pass preprocessing_layers=tf.nest.map_structure(lambda _: tf.keras.layers.Layer(), observation_spec)
We'll soon make this a bit easier with the new Sequential
and NestMap
networks being supported in addition to ActorDistributionNetwork
.
it's sad that the error message is so ugly. basically the structure of your preprocessing_layers
must match that of observation_spec
; in this case, it must be a dict
.
(but when you use tf_agents.networks.Sequential
, the first layer can just be tf_agents.networks.NestFlatten()
layer.)
I'm wrapping a pybullet environment in the gym wrapper with multiple different observations returned from the environment
I'm trying to filter and feed certain observations into an actor network (some are withheld). I assumed I could use a preprocessing_combiner to do this.
However, I get a key error:
This is happening in the call to preprocessing_combiner in the encoding network. I'm assuming this is because the dictionaries are not being appropriately denested and at some point a dictionary is assumed to be an array and indexed with 0.
As a simple example, the following fails
It works if I flatten the dictionary before setting the observation spec and while feeding in the observation
however, the previous solution requires modifying every call to actor/value networks to ensure that the flattened observations are passed. Is there no method for feeding in a dictionary of observations in?