-
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
ValueError: Only scalar actions are supported now!! #665
Comments
Change your action spec to |
I'm getting a similar error, but I cannot apply the solution by @sguada above, because I need my action to be a tuple of two integers. My action_spec:
The error I'm getting:
Any advice on what I might be doing wrong? |
As the error message shows, only scalar actions are supported for DQN, you can however transform your environment to have 1 action which represents the cross-product of all your actions. |
Yeah you could manually convert the tuple of actions back and forth, or use
FlattenActionWrapper
https://github.com/tensorflow/agents/blob/master/tf_agents/environments/wrappers.py#L274
To do it automatically.
Sergio
…On Mon, Oct 11, 2021 at 12:19 PM Andrei Yarmak ***@***.***> wrote:
Or do you mean something like action = action1 * 10 + action2, and then
action1, action2 = action // 10, action % 10?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#665 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANPI7E2HH7UZ3RX5TL4HGTUGM2CXANCNFSM5FB5MRBQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Thanks a lot - this is super helpful @sguada !! |
Hi, @sguada However, when I tried the following code
the following error pop up
Thanks in advance. Best Regards, |
Hi, my action need to be a tuple of three integers. I am using a DQN agent and a custom PyEnvironment environment. I am also getting same error as Jack has shown above when I use FlattenActionWrapper. Please let me know if some one was able to resolve this. |
I am getting this error while trying to create a custom environment and feed it to the DQN agent.
ValueError: Only scalar actions are supported now, but action spec is: BoundedTensorSpec(shape=(1,), dtype=tf.float32, name='action', minimum=array(0., dtype=float32), maximum=array(1., dtype=float32))
In call to configurable 'DqnAgent' (<class 'tf_agents.agents.dqn.dqn_agent.DqnAgent'>)
Here is my action_spec:
self._action_spec = array_spec.BoundedArraySpec(shape = (1,), dtype = np.float32, minimum = 0, maximum = 1, name = 'action')
The text was updated successfully, but these errors were encountered: