hive.agents.qnets.qnet_heads module
- class hive.agents.qnets.qnet_heads.DQNNetwork(base_network, hidden_dim, out_dim, linear_fn=None)[source]
Bases:
ModuleImplements the standard DQN value computation. Transforms output from
base_networkwith output dimensionhidden_dimto dimensionout_dim, which should be equal to the number of actions.- Parameters
base_network (torch.nn.Module) – Backbone network that computes the representations that are used to compute action values.
hidden_dim (int) – Dimension of the output of the
network.out_dim (int) – Output dimension of the DQN. Should be equal to the number of actions that you are computing values for.
linear_fn (torch.nn.Module) – Function that will create the
torch.nn.Modulethat will take the output ofnetworkand produce the final action values. IfNone, atorch.nn.Linearlayer will be used.
- forward(x)[source]
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class hive.agents.qnets.qnet_heads.DuelingNetwork(base_network, hidden_dim, out_dim, linear_fn=None, atoms=1)[source]
Bases:
ModuleComputes action values using Dueling Networks (https://arxiv.org/abs/1511.06581). In dueling, we have two heads—one for estimating advantage function and one for estimating value function.
- Parameters
base_network (torch.nn.Module) – Backbone network that computes the representations that are shared by the two estimators.
hidden_dim (int) – Dimension of the output of the
base_network.out_dim (int) – Output dimension of the Dueling DQN. Should be equal to the number of actions that you are computing values for.
linear_fn (torch.nn.Module) – Function that will create the
torch.nn.Modulethat will take the output ofnetworkand produce the final action values. IfNone, atorch.nn.Linearlayer will be used.atoms (int) – Multiplier for the dimension of the output. For standard dueling networks, this should be 1. Used by
DistributionalNetwork.
- forward(x)[source]
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class hive.agents.qnets.qnet_heads.DistributionalNetwork(base_network, out_dim, vmin=0, vmax=200, atoms=51)[source]
Bases:
ModuleComputes a categorical distribution over values for each action (https://arxiv.org/abs/1707.06887).
- Parameters
base_network (torch.nn.Module) – Backbone network that computes the representations that are used to compute the value distribution.
out_dim (int) – Output dimension of the Distributional DQN. Should be equal to the number of actions that you are computing values for.
vmin (float) – The minimum of the support of the categorical value distribution.
vmax (float) – The maximum of the support of the categorical value distribution.
atoms (int) – Number of atoms discretizing the support range of the categorical value distribution.
- forward(x)[source]
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.