agents icon indicating copy to clipboard operation
agents copied to clipboard

Keras model usage

Open teaglin opened this issue 2 years ago • 0 comments

I'm trying to get a custom Keras model to work with DDPG agent, but having no luck. I looked at this question. https://github.com/tensorflow/agents/issues/457

It did not work. Ideally I need to be able to save out the underlying Keras model to convert. It is destined for an edge device that can not run tensorflow. Is there a tutorial on using keras models?

ValueError: actor_network output spec does not match action spec:
TensorSpec(shape=(1,), dtype=tf.float32, name=None)
vs.
BoundedTensorSpec(shape=(), dtype=tf.float32, name='action', minimum=array(-1., dtype=float32), maximum=array(17.6, dtype=float32))
  In call to configurable 'ActorPolicy' (<class 'tf_agents.policies.actor_policy.ActorPolicy'>)
  In call to configurable 'DdpgAgent' (<class 'tf_agents.agents.ddpg.ddpg_agent.DdpgAgent'>)

This is the model. Both the spec and model only have 1 action. I don't quite understand this error.

input_1 (InputLayer)         [(None, 32)]              0         
_________________________________________________________________
dense (Dense)                (None, 64)                2112      
_________________________________________________________________
dense_1 (Dense)              (None, 16)                1040      
_________________________________________________________________
dense_2 (Dense)              (None, 1)                 17        
_________________________________________________________________

teaglin avatar Sep 01 '22 22:09 teaglin