|TensorFlow 1 version||View source on GitHub|
Clips tensor values to a maximum L2-norm.
Compat aliases for migration
See Migration guide for more details.
tf.clip_by_norm( t, clip_norm, axes=None, name=None )
Used in the notebooks
|Used in the guide|
Given a tensor
t, and a maximum clip value
clip_norm, this operation
t so that its L2-norm is less than or equal to
along the dimensions given in
axes. Specifically, in the default case
where all dimensions are used for calculation, if the L2-norm of
already less than or equal to
t is not modified. If
the L2-norm is greater than
clip_norm, then this operation returns a
tensor of the same type and shape as
t with its values set to:
t * clip_norm / l2norm(t)
In this case, the L2-norm of the output tensor is
As another example, if
t is a matrix and
axes == , then each row
of the output will have L2-norm less than or equal to
axes ==  instead, each column of the output will be clipped.
This operation is typically used to clip gradients before applying them with an optimizer.
A 0-D (scalar)
A 1-D (vector)
||A name for the operation (optional).|
||If the clip_norm tensor is not a 0-D scalar tensor.|
||If dtype of the input is not a floating point or complex type.|