hive.agents.qnets.td3_heads module

class hive.agents.qnets.td3_heads.TD3ActorNetwork(representation_network, actor_net, network_output_shape, action_shape, use_tanh=True)[source]

Bases: Module

A module that implements the TD3 actor computation. It puts together the representation_network and actor_net, and adds a final Linear layer to compute the action.

Parameters
  • representation_network (torch.nn.Module) – Network that encodes the observations.

  • actor_net (FunctionApproximator) – Function that takes in the shape of the encoded observations and creates a network. This network takes the encoded observations from representation_net and outputs the representations used to compute the actions (ie everything except the last layer).

  • network_output_shape (Union[int, Tuple[int]]) – Expected output shape of the representation network.

  • action_shape (Tuple[int]) – Requiured shape of the output action.

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 Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class hive.agents.qnets.td3_heads.TD3CriticNetwork(representation_network, critic_net, network_output_shape, n_critics, action_shape)[source]

Bases: Module

Parameters
  • representation_network (torch.nn.Module) – Network that encodes the observations.

  • critic_net (FunctionApproximator) – Function that takes in the shape of the encoded observations and creates a network. This network takes two inputs: the encoded observations from representation_net and actions. It outputs the representations used to compute the values of the actions (ie everything except the last layer).

  • network_output_shape (Union[int, Tuple[int]]) – Expected output shape of the representation network.

  • n_critics (int) – How many copies of the critic to create. They will all use the shared representation from the representation_network.

  • action_shape (Tuple[int]) – Expected shape of actions.

forward(obs, actions)[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 Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

q1(obs, actions)[source]

Returns the value according to only the first critic.

training: bool