chainer.optimizer_hooks.GradientClipping

class chainer.optimizer_hooks.GradientClipping(threshold)[source]

Optimizer hook function for gradient clipping.

This hook function scales all gradient arrays to fit to the defined L2 norm threshold.

Parameters

threshold (float) – L2 norm threshold.

Variables
  • ~optimizer_hooks.GradientClipping.threshold (float) – L2 norm threshold of gradient norm.

  • ~optimizer_hooks.GradientClipping.timing (string) – Specifies when this hook should be called by the Optimizer/UpdateRule. Valid values are ‘pre’ (before any updates) and ‘post’ (after any updates).

New in version 4.0.0: The timing parameter.

Methods

__call__(opt)[source]

Call self as a function.

__eq__(value, /)

Return self==value.

__ne__(value, /)

Return self!=value.

__lt__(value, /)

Return self<value.

__le__(value, /)

Return self<=value.

__gt__(value, /)

Return self>value.

__ge__(value, /)

Return self>=value.

Attributes

name = 'GradientClipping'
timing = 'pre'