pytorch_forecasting.metrics.distributions.LogNormalDistributionLoss#
- class pytorch_forecasting.metrics.distributions.LogNormalDistributionLoss(clamp_min: float = 1e-12, **kwargs)[source]#
Log-normal loss.
- Requirements for original target normalizer:
normalized target in log space
- Parameters:
clamp_min (float, optional) – Minimum value to clamp targets to before computing log-prob, preventing
ValueErrorwhen targets contain zeros. Defaults to 1e-12.
Initialize LogNormalDistributionLoss.
- Parameters:
clamp_min (float, optional) – Minimum value to clamp targets to before computing log-prob, preventing
ValueErrorwhen targets contain zeros. Defaults to 1e-12.**kwargs – Additional keyword arguments passed to
DistributionLoss.
- __init__(clamp_min: float = 1e-12, **kwargs)[source]#
Initialize LogNormalDistributionLoss.
- Parameters:
clamp_min (float, optional) – Minimum value to clamp targets to before computing log-prob, preventing
ValueErrorwhen targets contain zeros. Defaults to 1e-12.**kwargs – Additional keyword arguments passed to
DistributionLoss.
Methods
__abs__()Construct compositional metric using the absolute operator.
__add__(metric)Construct compositional metric using the addition operator.
__and__(other)Construct compositional metric using the logical and operator.
__call__(*args, **kwargs)Call self as a function.
__delattr__(name)Implement delattr(self, name).
__dir__()Default dir() implementation.
__eq__(other)Construct compositional metric using the equal operator.
__floordiv__(other)Construct compositional metric using the floor division operator.
__format__(format_spec, /)Default object formatter.
__ge__(other)Construct compositional metric using the greater than or equal operator.
__getattr__(name)__getattribute__(name, /)Return getattr(self, name).
__getitem__(idx)Construct compositional metric using the get item operator.
__getnewargs__()Needed method for construction of new metrics __new__ method.
__getstate__()Get the current state, including all metric states, for the metric.
__gt__(other)Construct compositional metric using the greater than operator.
__hash__()Return an unique hash of the metric.
__init_subclass__This method is called when a class is subclassed.
__inv__()Construct compositional metric using the not operator.
__invert__()Construct compositional metric using the not operator.
__le__(other)Construct compositional metric using the less than or equal operator.
__lt__(other)Construct compositional metric using the less than operator.
__matmul__(other)Construct compositional metric using the matrix multiplication operator.
__mod__(other)Construct compositional metric using the remainder operator.
__mul__(multiplier)Construct compositional metric using the multiplication operator.
__ne__(other)Construct compositional metric using the not equal operator.
__neg__()Construct compositional metric using absolute negative operator.
__new__(*args, **kwargs)__or__(other)Construct compositional metric using the logical or operator.
__pos__()Construct compositional metric using absolute operator.
__pow__(other)Construct compositional metric using the exponential/power operator.
__radd__(other)Construct compositional metric using the addition operator.
__rand__(other)Construct compositional metric using the logical and operator.
__reduce__()Helper for pickle.
__reduce_ex__(protocol, /)Helper for pickle.
__repr__()Return repr(self).
__rfloordiv__(other)Construct compositional metric using the floor division operator.
__rmatmul__(other)Construct compositional metric using the matrix multiplication operator.
__rmod__(other)Construct compositional metric using the remainder operator.
__rmul__(multiplier)Construct compositional metric using the multiplication operator.
__ror__(other)Construct compositional metric using the logical or operator.
__rpow__(other)Construct compositional metric using the exponential/power operator.
__rsub__(other)Construct compositional metric using the subtraction operator.
__rtruediv__(other)Construct compositional metric using the true divide operator.
__rxor__(other)Construct compositional metric using the logical xor operator.
__setattr__(name, value)Overwrite default method to prevent specific attributes from being set by user.
__setstate__(state)Set the state of the metric, based on a input state.
__sizeof__()Size of object in memory, in bytes.
__str__()Return str(self).
__sub__(other)Construct compositional metric using the subtraction operator.
__subclasshook__Abstract classes can override this to customize issubclass().
__truediv__(other)Construct compositional metric using the true divide operator.
__xor__(other)Construct compositional metric using the logical xor operator.
_apply(fn[, exclude_state])Overwrite _apply function such that we can also move metric states to the correct device.
_call_impl(*args, **kwargs)_copy_state_dict()Copy the current state values.
_filter_kwargs(**kwargs)Filter kwargs such that they match the update signature of the metric.
_forward_full_state_update(*args, **kwargs)Forward computation using two calls to update.
_forward_reduce_state_update(*args, **kwargs)Forward computation using single call to update.
_get_backward_hooks()Return the backward hooks for use in the call function.
_get_backward_pre_hooks()_get_name()_load_from_state_dict(state_dict, prefix, ...)Load metric states from state_dict.
_maybe_warn_non_full_backward_hook(inputs, ...)_move_list_states_to_cpu()Move list states to cpu to save GPU memory.
_named_members(get_members_fn[, prefix, ...])Help yield various names + members of modules.
_plot([val, ax])Plot a single or multiple values from the metric.
_reduce_states(incoming_state)Add an incoming metric state to the current state of the metric.
_register_load_state_dict_pre_hook(hook[, ...])See
register_load_state_dict_pre_hook()for details._register_state_dict_hook(hook)Register a post-hook for the
state_dict()method._replicate_for_data_parallel()_save_to_state_dict(destination, prefix, ...)Save module state to the destination dictionary.
_slow_forward(*input, **kwargs)_sync_dist(dist_sync_fn, process_group)_update_losses_and_lengths(losses, lengths)_wrap_compute(compute)_wrap_update(update)_wrapped_call_impl(*args, **kwargs)add_module(name, module)Add a child module to the current module.
add_state(name, default[, dist_reduce_fx, ...])Add metric state variable.
apply(fn)Apply
fnrecursively to every submodule (as returned by.children()) as well as self.bfloat16()Casts all floating point parameters and buffers to
bfloat16datatype.buffers([recurse])Return an iterator over module buffers.
children()Return an iterator over immediate children modules.
clone()Make a copy of the metric.
compile(*args, **kwargs)Compile this Module's forward using
torch.compile().compute()Abstract method that calculates metric
cpu()Move all model parameters and buffers to the CPU.
cuda([device])Move all model parameters and buffers to the GPU.
double()Override default and prevent dtype casting.
eval()Set the module in evaluation mode.
extra_repr()Return the extra representation of the module.
float()Override default and prevent dtype casting.
forward(*args, **kwargs)Aggregate and evaluate batch input directly.
get_buffer(target)Return the buffer given by
targetif it exists, otherwise throw an error.get_extra_state()Return any extra state to include in the module's state_dict.
get_parameter(target)Return the parameter given by
targetif it exists, otherwise throw an error.get_submodule(target)Return the submodule given by
targetif it exists, otherwise throw an error.half()Override default and prevent dtype casting.
ipu([device])Move all model parameters and buffers to the IPU.
load_state_dict(state_dict[, strict, assign])Copy parameters and buffers from
state_dictinto this module and its descendants.loss(y_pred, y_actual)Calculate negative log-likelihood.
map_x_to_distribution(x)Map network output to a LogNormal distribution.
mask_losses(losses, lengths[, reduction])Mask losses.
merge_state(incoming_state)Merge incoming metric state to the current state of the metric.
modules([remove_duplicate])Return an iterator over all modules in the network.
mtia([device])Move all model parameters and buffers to the MTIA.
named_buffers([prefix, recurse, ...])Return an iterator over module buffers, yielding both the name of the buffer as well as the buffer itself.
named_children()Return an iterator over immediate children modules, yielding both the name of the module as well as the module itself.
named_modules([memo, prefix, remove_duplicate])Return an iterator over all modules in the network, yielding both the name of the module as well as the module itself.
named_parameters([prefix, recurse, ...])Return an iterator over module parameters, yielding both the name of the parameter as well as the parameter itself.
parameters([recurse])Return an iterator over module parameters.
persistent([mode])Change post-init if metric states should be saved to its state_dict.
plot(*_, **__)Override this method plot the metric value.
reduce_loss(losses, lengths[, reduction])Reduce loss.
register_backward_hook(hook)Register a backward hook on the module.
register_buffer(name, tensor[, persistent])Add a buffer to the module.
register_forward_hook(hook, *[, prepend, ...])Register a forward hook on the module.
register_forward_pre_hook(hook, *[, ...])Register a forward pre-hook on the module.
register_full_backward_hook(hook[, prepend])Register a backward hook on the module.
register_full_backward_pre_hook(hook[, prepend])Register a backward pre-hook on the module.
register_load_state_dict_post_hook(hook)Register a post-hook to be run after module's
load_state_dict()is called.register_load_state_dict_pre_hook(hook)Register a pre-hook to be run before module's
load_state_dict()is called.register_module(name, module)Alias for
add_module().register_parameter(name, param)Add a parameter to the module.
register_state_dict_post_hook(hook)Register a post-hook for the
state_dict()method.register_state_dict_pre_hook(hook)Register a pre-hook for the
state_dict()method.requires_grad_([requires_grad])Change if autograd should record operations on parameters in this module.
rescale_parameters(parameters, target_scale, ...)Rescale normalized parameters into the scale required for the output.
reset()Reset metric state variables to their default value.
sample(y_pred, n_samples)Sample from distribution.
set_dtype(dst_type)Transfer all metric state to specific dtype.
set_extra_state(state)Set extra state contained in the loaded state_dict.
set_submodule(target, module[, strict])Set the submodule given by
targetif it exists, otherwise throw an error.share_memory()See
torch.Tensor.share_memory_().state_dict([destination, prefix, keep_vars])Get the current state of metric as an dictionary.
sync([dist_sync_fn, process_group, ...])Sync function for manually controlling when metrics states should be synced across processes.
sync_context([dist_sync_fn, process_group, ...])Context manager to synchronize states.
to(*args, **kwargs)Move and/or cast the parameters and buffers.
to_empty(*, device[, recurse])Move the parameters and buffers to the specified device without copying storage.
to_prediction(y_pred[, n_samples])Convert network prediction into a point prediction.
to_quantiles(y_pred[, quantiles, n_samples])Convert network prediction into a quantile prediction.
train([mode])Set the module in training mode.
type(dst_type)Override default and prevent dtype casting.
unsync([should_unsync])Unsync function for manually controlling when metrics states should be reverted back to their local states.
update(y_pred, target)Update method of metric that handles masking of values.
xpu([device])Move all model parameters and buffers to the XPU.
zero_grad([set_to_none])Reset gradients of all model parameters.
Attributes
T_destination__abstractmethods____annotations____dict____doc____iter____jit_ignored_attributes____jit_unused_properties____module____slots____weakref__list of weak references to the object
_abc_impl_compiled_call_impl_update_called_versionThis allows better BC support for
load_state_dict().call_super_initdeviceReturn the device of the metric.
distribution_argumentsdtypeReturn the default dtype of the metric.
dump_patchesfull_state_updatehigher_is_betteris_differentiablemetric_stateGet the current state of the metric.
plot_legend_nameplot_lower_boundplot_upper_boundupdate_calledReturns True if update or forward has been called initialization or last reset.
update_countGet the number of times update and/or forward has been called since initialization or last reset.
training_parameters_buffers_non_persistent_buffers_set_backward_pre_hooks_backward_hooks_is_full_backward_hook_forward_hooks_forward_hooks_with_kwargs_forward_hooks_always_called_forward_pre_hooks_forward_pre_hooks_with_kwargs_state_dict_hooks_load_state_dict_pre_hooks_state_dict_pre_hooks_load_state_dict_post_hooks_modules