gluonts.mx.distribution.binned module¶
-
class
gluonts.mx.distribution.binned.
Binned
(bin_log_probs: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], bin_centers: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], label_smoothing: Optional[float] = None)[source]¶ Bases:
gluonts.mx.distribution.distribution.Distribution
A binned distribution defined by a set of bins via bin centers and bin probabilities.
- Parameters
bin_log_probs – Tensor containing log probabilities of the bins, of shape (*batch_shape, num_bins).
bin_centers – Tensor containing the bin centers, of shape (*batch_shape, num_bins).
F –
label_smoothing – The label smoothing weight, real number in [0, 1). Default None. If not None, then the loss of the distribution will be “label smoothed” cross-entropy. For example, instead of computing cross-entropy loss between the estimated bin probabilities and a hard-label (one-hot encoding) [1, 0, 0], a soft label of [0.9, 0.05, 0.05] is taken as the ground truth (when label_smoothing=0.15). See (Muller et al., 2019) [MKH19], for further reference.
-
property
F
¶
-
arg_names
= None¶
-
property
args
¶
-
property
batch_shape
¶ Layout of the set of events contemplated by the distribution.
Invoking sample() from a distribution yields a tensor of shape batch_shape + event_shape, and computing log_prob (or loss more in general) on such sample will yield a tensor of shape batch_shape.
This property is available in general only in mx.ndarray mode, when the shape of the distribution arguments can be accessed.
-
property
bin_probs
¶
-
cdf
(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]¶ Returns the value of the cumulative distribution function evaluated at x
-
property
event_dim
¶ Number of event dimensions, i.e., length of the event_shape tuple.
This is 0 for distributions over scalars, 1 over vectors, 2 over matrices, and so on.
-
property
event_shape
¶ Shape of each individual event contemplated by the distribution.
For example, distributions over scalars have event_shape = (), over vectors have event_shape = (d, ) where d is the length of the vectors, over matrices have event_shape = (d1, d2), and so on.
Invoking sample() from a distribution yields a tensor of shape batch_shape + event_shape.
This property is available in general only in mx.ndarray mode, when the shape of the distribution arguments can be accessed.
-
is_reparameterizable
= False¶
-
log_prob
(x)[source]¶ Compute the log-density of the distribution at x.
- Parameters
x – Tensor of shape (*batch_shape, *event_shape).
- Returns
Tensor of shape batch_shape containing the log-density of the distribution for each event in x.
- Return type
Tensor
-
loss
(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]¶ Compute the loss at x according to the distribution.
By default, this method returns the negative of log_prob. For some distributions, however, the log-density is not easily computable and therefore other loss functions are computed.
- Parameters
x – Tensor of shape (*batch_shape, *event_shape).
- Returns
Tensor of shape batch_shape containing the value of the loss for each event in x.
- Return type
Tensor
-
property
mean
¶ Tensor containing the mean of the distribution.
-
quantile
(level: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]¶ Calculates quantiles for the given levels.
- Parameters
level – Level values to use for computing the quantiles. level should be a 1d tensor of level values between 0 and 1.
- Returns
Quantile values corresponding to the levels passed. The return shape is
(num_levels, …DISTRIBUTION_SHAPE…),
where DISTRIBUTION_SHAPE is the shape of the underlying distribution.
- Return type
quantiles
-
sample
(num_samples=None, dtype=<class 'numpy.float32'>)[source]¶ Draw samples from the distribution.
If num_samples is given the first dimension of the output will be num_samples.
- Parameters
num_samples – Number of samples to to be drawn.
dtype – Data-type of the samples.
- Returns
A tensor containing samples. This has shape (*batch_shape, *eval_shape) if num_samples = None and (num_samples, *batch_shape, *eval_shape) otherwise.
- Return type
Tensor
-
property
stddev
¶ Tensor containing the standard deviation of the distribution.
-
class
gluonts.mx.distribution.binned.
BinnedArgs
(num_bins: int, bin_centers: mxnet.ndarray.ndarray.NDArray, **kwargs)[source]¶ Bases:
mxnet.gluon.block.HybridBlock
-
hybrid_forward
(F, x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], bin_centers: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Tuple[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]][source]¶ Overrides to construct symbolic graph for this Block.
- Parameters
x (Symbol or NDArray) – The first input tensor.
*args (list of Symbol or list of NDArray) – Additional input tensors.
-
-
class
gluonts.mx.distribution.binned.
BinnedOutput
(bin_centers: mxnet.ndarray.ndarray.NDArray, label_smoothing: Optional[float] = None)[source]¶ Bases:
gluonts.mx.distribution.distribution_output.DistributionOutput
-
distribution
(args, loc=None, scale=None) → gluonts.mx.distribution.binned.Binned[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.
-
property
event_shape
¶ Shape of each individual event contemplated by the distributions that this object constructs.
-