allenact.base_abstractions.distributions
#
TeacherForcingAnnealingType
#
Modify standard PyTorch distributions so they are compatible with this code.
Distr
#
class Distr(abc.ABC)
Distr.log_prob
#
| @abc.abstractmethod
| log_prob(actions: Any)
Return the log probability/ies of the provided action/s.
Distr.entropy
#
| @abc.abstractmethod
| entropy()
Return the entropy or entropies.
Distr.sample
#
| @abc.abstractmethod
| sample(sample_shape=torch.Size())
Sample actions.
Distr.mode
#
| mode()
If available, return the action(s) with highest probability.
It will only be called if using deterministic agents.
CategoricalDistr
#
class CategoricalDistr(torch.distributions.Categorical, Distr)
A categorical distribution extending PyTorch's Categorical.
probs or logits are assumed to be passed with step and sampler dimensions as in: [step, samplers, ...]
ConditionalDistr
#
class ConditionalDistr(Distr)
Action distribution conditional which is conditioned on other information (i.e. part of a hierarchical distribution)
Attributes
action_group_name
: the identifier of the group of actions (OrderedDict
) produced by thisConditionalDistr
ConditionalDistr.__init__
#
| __init__(distr_conditioned_on_input_fn_or_instance: Union[Callable, Distr], action_group_name: str, *distr_conditioned_on_input_args, **distr_conditioned_on_input_kwargs, *, ,)
Initialize an ConditionalDistr.
Parameters
- distr_conditioned_on_input_fn_or_instance : Callable to generate
ConditionalDistr
given sampled actions, or givenDistr
. - action_group_name : the identifier of the group of actions (
OrderedDict
) produced by thisConditionalDistr
- distr_conditioned_on_input_args : positional arguments for Callable
distr_conditioned_on_input_fn_or_instance
- distr_conditioned_on_input_kwargs : keyword arguments for Callable
distr_conditioned_on_input_fn_or_instance
AddBias
#
class AddBias(nn.Module)
Adding bias parameters to input values.
AddBias.__init__
#
| __init__(bias: torch.FloatTensor)
Initializer.
Parameters
- bias : data to use as the initial values of the bias.
AddBias.forward
#
| forward(x: torch.FloatTensor) -> torch.FloatTensor
Adds the stored bias parameters to x
.