Log Cosh Error¶
Module Interface¶
- class torchmetrics.LogCoshError(num_outputs=1, **kwargs)[source]
Compute the LogCosh Error.
Where
is a tensor of target values, and
is a tensor of predictions.
As input to
forward
andupdate
the metric accepts the following input:preds
(Tensor
): Estimated labels with shape(batch_size,)
or(batch_size, num_outputs)
target
(Tensor
): Ground truth labels with shape(batch_size,)
or(batch_size, num_outputs)
As output of
forward
andcompute
the metric returns the following output:log_cosh_error
(Tensor
): A tensor with the log cosh error
- Parameters
num_outputs¶ (
int
) – Number of outputs in multioutput settingkwargs¶ (
Any
) – Additional keyword arguments, see Advanced metric settings for more info.
- Example (single output regression)::
>>> from torchmetrics import LogCoshError >>> preds = torch.tensor([3.0, 5.0, 2.5, 7.0]) >>> target = torch.tensor([2.5, 5.0, 4.0, 8.0]) >>> log_cosh_error = LogCoshError() >>> log_cosh_error(preds, target) tensor(0.3523)
- Example (multi output regression)::
>>> from torchmetrics import LogCoshError >>> preds = torch.tensor([[3.0, 5.0, 1.2], [-2.1, 2.5, 7.0]]) >>> target = torch.tensor([[2.5, 5.0, 1.3], [0.3, 4.0, 8.0]]) >>> log_cosh_error = LogCoshError(num_outputs=3) >>> log_cosh_error(preds, target) tensor([0.9176, 0.4277, 0.2194])
Initializes internal Module state, shared by both nn.Module and ScriptModule.
Functional Interface¶
- torchmetrics.functional.log_cosh_error(preds, target)[source]
Compute the LogCosh Error.
Where
is a tensor of target values, and
is a tensor of predictions.
- Parameters
- Return type
- Returns
Tensor with LogCosh error
- Example (single output regression)::
>>> from torchmetrics.functional import log_cosh_error >>> preds = torch.tensor([3.0, 5.0, 2.5, 7.0]) >>> target = torch.tensor([2.5, 5.0, 4.0, 8.0]) >>> log_cosh_error(preds, target) tensor(0.3523)
- Example (multi output regression)::
>>> from torchmetrics.functional import log_cosh_error >>> preds = torch.tensor([[3.0, 5.0, 1.2], [-2.1, 2.5, 7.0]]) >>> target = torch.tensor([[2.5, 5.0, 1.3], [0.3, 4.0, 8.0]]) >>> log_cosh_error(preds, target) tensor([0.9176, 0.4277, 0.2194])