gluonts.torch.modules.distribution_output module

class gluonts.torch.modules.distribution_output.BetaOutput[source]

Bases: gluonts.torch.modules.distribution_output.DistributionOutput

args_dim: Dict[str, int] = {'concentration0': 1, 'concentration1': 1}
distr_cls

alias of torch.distributions.beta.Beta

classmethod domain_map(concentration1: torch.Tensor, concentration0: torch.Tensor)[source]

Converts arguments to the right shape and domain. The domain depends on the type of distribution, while the correct shape is obtained by reshaping the trailing axis in such a way that the returned tensors define a distribution of the right event_shape.

property event_shape

Shape of each individual event contemplated by the distributions that this object constructs.

property value_in_support

A float that will have a valid numeric value when computing the log-loss of the corresponding distribution. By default 0.0. This value will be used when padding data series.

class gluonts.torch.modules.distribution_output.DistributionOutput[source]

Bases: gluonts.torch.modules.distribution_output.Output

Class to construct a distribution given the output of a network.

distr_cls: type = None
distribution(distr_args, loc: Optional[torch.Tensor] = None, scale: Optional[torch.Tensor] = None) → torch.distributions.distribution.Distribution[source]

Construct the associated distribution, given the collection of constructor arguments and, optionally, a scale tensor.

Parameters
  • distr_args – Constructor arguments for the underlying Distribution type.

  • loc – Optional tensor, of the same shape as the batch_shape+event_shape of the resulting distribution.

  • scale – Optional tensor, of the same shape as the batch_shape+event_shape of the resulting distribution.

domain_map(*args: torch.Tensor)[source]

Converts arguments to the right shape and domain. The domain depends on the type of distribution, while the correct shape is obtained by reshaping the trailing axis in such a way that the returned tensors define a distribution of the right event_shape.

property event_dim

Number of event dimensions, i.e., length of the event_shape tuple, of the distributions that this object constructs.

property event_shape

Shape of each individual event contemplated by the distributions that this object constructs.

property value_in_support

A float that will have a valid numeric value when computing the log-loss of the corresponding distribution. By default 0.0. This value will be used when padding data series.

class gluonts.torch.modules.distribution_output.GammaOutput[source]

Bases: gluonts.torch.modules.distribution_output.DistributionOutput

args_dim: Dict[str, int] = {'concentration': 1, 'rate': 1}
distr_cls

alias of torch.distributions.gamma.Gamma

classmethod domain_map(concentration: torch.Tensor, rate: torch.Tensor)[source]

Converts arguments to the right shape and domain. The domain depends on the type of distribution, while the correct shape is obtained by reshaping the trailing axis in such a way that the returned tensors define a distribution of the right event_shape.

property event_shape

Shape of each individual event contemplated by the distributions that this object constructs.

property value_in_support

A float that will have a valid numeric value when computing the log-loss of the corresponding distribution. By default 0.0. This value will be used when padding data series.

class gluonts.torch.modules.distribution_output.NegativeBinomialOutput[source]

Bases: gluonts.torch.modules.distribution_output.DistributionOutput

args_dim: Dict[str, int] = {'logits': 1, 'total_count': 1}
distr_cls

alias of torch.distributions.negative_binomial.NegativeBinomial

classmethod domain_map(total_count: torch.Tensor, logits: torch.Tensor)[source]

Converts arguments to the right shape and domain. The domain depends on the type of distribution, while the correct shape is obtained by reshaping the trailing axis in such a way that the returned tensors define a distribution of the right event_shape.

property event_shape

Shape of each individual event contemplated by the distributions that this object constructs.

class gluonts.torch.modules.distribution_output.NormalOutput[source]

Bases: gluonts.torch.modules.distribution_output.DistributionOutput

args_dim: Dict[str, int] = {'loc': 1, 'scale': 1}
distr_cls

alias of torch.distributions.normal.Normal

classmethod domain_map(loc: torch.Tensor, scale: torch.Tensor)[source]

Converts arguments to the right shape and domain. The domain depends on the type of distribution, while the correct shape is obtained by reshaping the trailing axis in such a way that the returned tensors define a distribution of the right event_shape.

property event_shape

Shape of each individual event contemplated by the distributions that this object constructs.

class gluonts.torch.modules.distribution_output.Output[source]

Bases: object

Class to connect a network to some output

args_dim: Dict[str, int] = None
domain_map(*args: torch.Tensor)[source]
property dtype
get_args_proj(in_features: int) → torch.nn.modules.module.Module[source]
in_features: int = None
class gluonts.torch.modules.distribution_output.PoissonOutput[source]

Bases: gluonts.torch.modules.distribution_output.DistributionOutput

args_dim: Dict[str, int] = {'rate': 1}
distr_cls

alias of torch.distributions.poisson.Poisson

classmethod domain_map(rate: torch.Tensor)[source]

Converts arguments to the right shape and domain. The domain depends on the type of distribution, while the correct shape is obtained by reshaping the trailing axis in such a way that the returned tensors define a distribution of the right event_shape.

property event_shape

Shape of each individual event contemplated by the distributions that this object constructs.

class gluonts.torch.modules.distribution_output.PtArgProj(in_features: int, args_dim: Dict[str, int], domain_map: Callable[[...], Tuple[torch.Tensor]], **kwargs)[source]

Bases: torch.nn.modules.module.Module

A PyTorch module that can be used to project from a dense layer to PyTorch distribution arguments.

Parameters
  • in_features – Size of the incoming features.

  • dim_args – Dictionary with string key and int value dimension of each arguments that will be passed to the domain map, the names are not used.

  • domain_map – Function returning a tuple containing one tensor a function or a nn.Module. This will be called with num_args arguments and should return a tuple of outputs that will be used when calling the distribution constructor.

forward(x: torch.Tensor) → Tuple[torch.Tensor][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 = None
class gluonts.torch.modules.distribution_output.StudentTOutput[source]

Bases: gluonts.torch.modules.distribution_output.DistributionOutput

args_dim: Dict[str, int] = {'df': 1, 'loc': 1, 'scale': 1}
distr_cls

alias of torch.distributions.studentT.StudentT

classmethod domain_map(df: torch.Tensor, loc: torch.Tensor, scale: torch.Tensor)[source]

Converts arguments to the right shape and domain. The domain depends on the type of distribution, while the correct shape is obtained by reshaping the trailing axis in such a way that the returned tensors define a distribution of the right event_shape.

property event_shape

Shape of each individual event contemplated by the distributions that this object constructs.