gluonts.torch.distributions.output module#

class gluonts.torch.distributions.output.Output[source]#

Bases: object

Converts raw neural network output into a forecast and computes loss.

args_dim: Dict[str, int]#
domain_map(*args: torch.Tensor) Tuple[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 dtype#
property event_shape: Tuple#

Shape of each individual event compatible with the output object.

property forecast_generator: gluonts.model.forecast_generator.ForecastGenerator#
get_args_proj(in_features: int) torch.nn.modules.module.Module[source]#
in_features: int#
loss(target: torch.Tensor, distr_args: Tuple[torch.Tensor, ...], loc: Optional[torch.Tensor] = None, scale: Optional[torch.Tensor] = None) torch.Tensor[source]#

Compute loss for target data given network output.

Parameters
  • target – Values of the target time series for which loss is to be computed.

  • distr_args – Arguments that can be used to construct the output distribution.

  • loc – Location parameter of the distribution, optional.

  • scale – Scale parameter of the distribution, optional.

Returns

Values of the loss, has same shape as target.

Return type

loss_values

property value_in_support: float#

A float value that is valid for computing the loss of the corresponding output.

By default 0.0.

class gluonts.torch.distributions.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]#

Define 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#