You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[rllib] incorrect model output for DQN with torch and dueling=false #9366
P2Important issue, but not time-criticalbugSomething that is supposed to be working; but isn'ttriageNeeds triage (eg: priority, bug/not-bug, and owning component)
The output fo the DQN model is not within the action space.
Something is wrong when constructing the torch model when dueling is off. The output dimension of the model is equal to whatever is passed in "fcnet_hiddens" instead of being of the size of the action space.
Ray version and other system information (Python version, TensorFlow version, OS):
Can you just change the following in your rllib/agents/dqn/dqn_torch_model.py (c'tor) ?
advantage_module = nn.Sequential()
value_module = nn.Sequential()
# Dueling case: Build the shared (advantages and value) fc-network.
if self.dueling:
for i, n in enumerate(q_hiddens):
advantage_module.add_module("dueling_A_{}".format(i),
nn.Linear(ins, n))
value_module.add_module("dueling_V_{}".format(i),
nn.Linear(ins, n))
# Add activations if necessary.
if dueling_activation == "relu":
advantage_module.add_module("dueling_A_act_{}".format(i),
nn.ReLU())
value_module.add_module("dueling_V_act_{}".format(i),
nn.ReLU())
elif dueling_activation == "tanh":
advantage_module.add_module("dueling_A_act_{}".format(i),
nn.Tanh())
value_module.add_module("dueling_V_act_{}".format(i),
nn.Tanh())
# Add LayerNorm after each Dense.
if add_layer_norm:
advantage_module.add_module("LayerNorm_A_{}".format(i),
nn.LayerNorm(n))
value_module.add_module("LayerNorm_V_{}".format(i),
nn.LayerNorm(n))
ins = n
# Actual Advantages layer (nodes=num-actions) and
# value layer (nodes=1).
advantage_module.add_module("A", nn.Linear(ins, action_space.n))
value_module.add_module("V", nn.Linear(ins, 1))
This PR fixes the issue: #9386
Will be merged today into master. Thanks for filing this!
Closing it now. Please feel free to re-open should this still not work on your end.
P2Important issue, but not time-criticalbugSomething that is supposed to be working; but isn'ttriageNeeds triage (eg: priority, bug/not-bug, and owning component)
Activity
sven1977 commentedon Jul 9, 2020
Can you just change the following in your
rllib/agents/dqn/dqn_torch_model.py (c'tor)?That should fix it. Will PR now ...
sven1977 commentedon Jul 9, 2020
@MaximeBouton
MaximeBouton commentedon Jul 10, 2020
Just saw this, I can give it a try tomorrow morning
sven1977 commentedon Jul 10, 2020
This PR fixes the issue: #9386
Will be merged today into master. Thanks for filing this!
Closing it now. Please feel free to re-open should this still not work on your end.
[RLlib] Issue #9366 (DQN w/o dueling produces invalid actions). (#9386)
MaximeBouton commentedon Jul 10, 2020
I installed the nightly version and it works, thanks for the quick fix!
sven1977 commentedon Jul 10, 2020
This has been merged into master.
sven1977 commentedon Jul 11, 2020
Awesome! Glad it's working. :)
Syncing with upstream master 2020-07-30 (#21)
Edpalenc/1.3.0 bonsai sync (#69)