narla.neurons
Network
- class narla.neurons.Network[source]
Bases:
torch.nn.modules.module.Module
- abstract 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.- Return type
Tensor
- training: bool
Neuron
- class narla.neurons.Neuron(observation_size, number_of_actions, learning_rate)[source]
Bases:
object
Neuron base class
- Parameters
observation_size (
int
) – Size of the observation which the Neuron will receivenumber_of_actions (
int
) – Number of actions available to the Neuron
- abstract act(observation)[source]
Take an action based on the observation
- Parameters
observation (
Tensor
) – Observation from the Neuron’s local environment- Return type
Tensor
- property history: narla.history.history.History
Access the History of the Neuron
- Return type
- abstract learn(*reward_types)[source]
Update the Neuron’s internal Network
- Parameters
reward_types (
RewardTypes
) – RewardTypes to be used for learning
NeuronSettings
- class narla.neurons.NeuronSettings(learning_rate=0.0001, neuron_type=NeuronTypes.POLICY_GRADIENT)[source]
Bases:
narla.settings.base_settings.BaseSettings
- learning_rate: float = 0.0001
Learning rate for Neurons
- neuron_type: narla.neurons.neuron_types.NeuronTypes = 'policy_gradient'
Type of Neuron that will be used
NeuronTypes
actor_critic
Network
- class narla.neurons.actor_critic.Network(input_size, output_size, embedding_size=128)[source]
Bases:
narla.neurons.network.Network
- 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.- Return type
Tuple
[Tensor
,Tensor
]
- training: bool
Neuron
- class narla.neurons.actor_critic.Neuron(observation_size, number_of_actions, learning_rate=0.0001)[source]
Bases:
narla.neurons.neuron.Neuron
The ActorCritic Neuron is based on this PyTorch example
- Parameters
observation_size (
int
) – Size of the observation which the Neuron will receivenumber_of_actions (
int
) – Number of actions available to the Neuronlearning_rate (
float
) – Learning rate for the Neuron’s Network
- act(observation)[source]
Take an action based on the observation
- Parameters
observation (
Tensor
) – Observation from the Neuron’s local environment- Return type
Tensor
- learn(*reward_types)[source]
Update the Neuron’s internal Network
- Parameters
reward_types (
RewardTypes
) – RewardTypes to be used for learning
deep_q
Network
- class narla.neurons.deep_q.Network(input_size, output_size, embedding_size=128)[source]
Bases:
narla.neurons.network.Network
- 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
Neuron
- class narla.neurons.deep_q.Neuron(observation_size, number_of_actions, learning_rate=0.0001)[source]
Bases:
narla.neurons.neuron.Neuron
The DeepQ Neuron is based on this PyTorch example
- Parameters
observation_size (
int
) – Size of the observation which the Neuron will receivenumber_of_actions (
int
) – Number of actions available to the Neuronlearning_rate (
float
) – Learning rate for the Neuron’s Network
- act(observation)[source]
Take an action based on the observation
- Parameters
observation (
Tensor
) – Observation from the Neuron’s local environment- Return type
Tensor
- learn(*reward_types)[source]
Update the Neuron’s internal Network
- Parameters
reward_types (
RewardTypes
) – RewardTypes to be used for learning
policy_gradient
Network
- class narla.neurons.policy_gradient.Network(input_size, output_size, embedding_size=32)[source]
Bases:
narla.neurons.network.Network
- 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
Neuron
- class narla.neurons.policy_gradient.Neuron(observation_size, number_of_actions, learning_rate=0.01)[source]
Bases:
narla.neurons.neuron.Neuron
PolicyGradient Neuron
- Parameters
observation_size (
int
) – Size of the observation which the Neuron will receivenumber_of_actions (
int
) – Number of actions available to the Neuronlearning_rate (
float
) – Learning rate for the Neuron’s Network
- act(observation)[source]
Take an action based on the observation
- Parameters
observation (
Tensor
) – Observation from the Neuron’s local environment- Return type
Tensor
- learn(*reward_types)[source]
Update the Neuron’s internal Network
- Parameters
reward_types (
RewardTypes
) – RewardTypes to be used for learning