HuberLoss#

class vulkpy.nn.HuberLoss#

Bases: ReduceLoss

Huber Loss

Methods Summary

__call__(x, y)

Compute Loss

backward()

Backward

forward(x, y)

Forward

grad()

Compute Gradients

Methods Documentation

__call__(x: Array, y: Array) Array#

Compute Loss

Parameters:
Returns:

loss – Loss

Return type:

vulkpy.Array

backward() Array#

Backward

Returns:

loss – Batch gradients

Return type:

vulkpy.Array

Notes

\[dx = \text{clamp}(x - y, -1.0, 1.0)\]

Warning

Generally, users should not call this method directly. Use grad() instead, where reduction scale is corrected.

forward(x: Array, y: Array) Array#

Forward

Parameters:
Returns:

loss – Loss

Return type:

vulkpy.Array

Notes

\[L = 0.5 f _{\text{reduce}} \min(|x - y|^2, |x - y|)\]

Warning

Generally, users should not call this method directly. Use __call__ instead, where input / output are stored for training.

grad() Array#

Compute Gradients

Returns:

dx – Batch gradients of dL/dx

Return type:

vulkpy.Array

Notes

This method calculates gradients for the last __call__(x, y).

__init__(*args, **kwargs)#

Initialize Huber Loss

Parameters:

reduce ({"mean", "sum"}) – Reduction method over batch. The default is "mean".