Skip to content

allenact.base_abstractions.distributions#

[view_source]

TeacherForcingAnnealingType#

[view_source]

Modify standard PyTorch distributions so they are compatible with this code.

Distr#

class Distr(abc.ABC)

[view_source]

Distr.log_prob#

 | @abc.abstractmethod
 | log_prob(actions: Any)

[view_source]

Return the log probability/ies of the provided action/s.

Distr.entropy#

 | @abc.abstractmethod
 | entropy()

[view_source]

Return the entropy or entropies.

Distr.sample#

 | @abc.abstractmethod
 | sample(sample_shape=torch.Size())

[view_source]

Sample actions.

Distr.mode#

 | mode()

[view_source]

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)

[view_source]

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)

[view_source]

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 this ConditionalDistr

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, *, ,)

[view_source]

Initialize an ConditionalDistr

Parameters

  • distr_conditioned_on_input_fn_or_instance : Callable to generate ConditionalDistr given sampled actions, or given Distr.
  • action_group_name : the identifier of the group of actions (OrderedDict) produced by this ConditionalDistr
  • 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)

[view_source]

Adding bias parameters to input values.

AddBias.__init__#

 | __init__(bias: torch.FloatTensor)

[view_source]

Initializer.

Parameters

  • bias : data to use as the initial values of the bias.

AddBias.forward#

 | forward(x: torch.FloatTensor) -> torch.FloatTensor

[view_source]

Adds the stored bias parameters to x.