splendor.agents.our_agents.ppo.ppo_rnn.gru package
Submodules
splendor.agents.our_agents.ppo.ppo_rnn.gru.constants module
Constants regarding PPO with GRU.
splendor.agents.our_agents.ppo.ppo_rnn.gru.network module
PPO with GRU (Gated Recurrent Unit) implementation.
- class splendor.agents.our_agents.ppo.ppo_rnn.gru.network.PpoGru(input_dim: int, output_dim: int, hidden_layers_dims: list[int] | None = None, dropout: float = 0.2, hidden_state_dim: int = 64, recurrent_layers_num: int = 1)[source]
Bases:
RecurrentPPO
Implementation of PPO network architecture using a GRU.
- forward(x: Float[Tensor, 'batch sequence features'] | Float[Tensor, 'batch features'] | Float[Tensor, 'features'], action_mask: Float[Tensor, 'batch actions'] | Float[Tensor, 'actions'], hidden_state: tuple[Float[Tensor, 'batch num_layers hidden_dim'], None] | tuple[Float[Tensor, 'num_layers hidden_dim'], None], *args, **kwargs) tuple[Float[Tensor, 'batch actions'], Float[Tensor, 'batch 1'], Float[Tensor, 'batch hidden_dim'], None] [source]
Pass input through the network to gain predictions.
- Parameters:
x – the input to the network. expected shape: one of the following: (features,) or (batch_size, features) or (batch_size, sequance_length, features).
action_mask – a binary masking tensor, 1’s signals a valid action and 0’s signals an invalid action. expected shape: (actions,) or (batch_size, actions). where actions are equal to len(ALL_ACTIONS) which comes from Engine.Splendor.gym.envs.actions
hidden_state – hidden state of the recurrent unit. expected shape: (batch_size, num_layers, hidden_state_dim) or (num_layers, hidden_state_dim).
- Returns:
the actions probabilities, the value estimate and the next hidden state.
return the initial hidden state to be used.
splendor.agents.our_agents.ppo.ppo_rnn.gru.ppo_agent module
Implementation for a PPO agent which uses GRU in his neural network.
- class splendor.agents.our_agents.ppo.ppo_rnn.gru.ppo_agent.PpoGruAgent(_id: int, load_net: bool = True)[source]
Bases:
PPOAgentBase
PPO agent with GRU.
- SelectAction(actions: list[CollectAction | ReserveAction | BuyAction], game_state: SplendorState, game_rule: SplendorGameRule) CollectAction | ReserveAction | BuyAction [source]
select an action to play from the given actions.
- splendor.agents.our_agents.ppo.ppo_rnn.gru.ppo_agent.myAgent
alias of
PpoGruAgent