Given a tensor t, and a maximum clip value clip_norm, this operation
normalizes t so that its average L2-norm is less than or equal to
clip_norm. Specifically, if the average L2-norm is already less than or
equal to clip_norm, then t is not modified. If the average 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_avg(t)
In this case, the average L2-norm of the output tensor is clip_norm.
This operation is typically used to clip gradients before applying them with
an optimizer.
Args
t
A Tensor.
clip_norm
A 0-D (scalar) Tensor > 0. A maximum clipping value.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.compat.v1.clip_by_average_norm\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/ops/clip_ops.py#L395-L440) |\n\nClips tensor values to a maximum average L2-norm. (deprecated) \n\n tf.compat.v1.clip_by_average_norm(\n t, clip_norm, name=None\n )\n\n| **Deprecated:** THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: clip_by_average_norm is deprecated in TensorFlow 2.0. Please use clip_by_norm(t, clip_norm \\* tf.cast(tf.size(t), tf.float32), name) instead.\n\nGiven a tensor `t`, and a maximum clip value `clip_norm`, this operation\nnormalizes `t` so that its average L2-norm is less than or equal to\n`clip_norm`. Specifically, if the average L2-norm is already less than or\nequal to `clip_norm`, then `t` is not modified. If the average L2-norm is\ngreater than `clip_norm`, then this operation returns a tensor of the same\ntype and shape as `t` with its values set to:\n\n`t * clip_norm / l2norm_avg(t)`\n\nIn this case, the average L2-norm of the output tensor is `clip_norm`.\n\nThis operation is typically used to clip gradients before applying them with\nan optimizer.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------|---------------------------------------------------------|\n| `t` | A `Tensor`. |\n| `clip_norm` | A 0-D (scalar) `Tensor` \\\u003e 0. A maximum clipping value. |\n| `name` | A name for the operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A clipped `Tensor`. ||\n\n\u003cbr /\u003e"]]