clip_global_norm¶
-
clip_global_norm(arrays, max_norm, check_isfinite=True)¶ Rescales NDArrays so that the sum of their 2-norm is smaller than max_norm.
Parameters: - arrays : list of NDArray
- max_norm : float
- check_isfinite : bool, default True
If True, check that the total_norm is finite (not nan or inf). This requires a blocking .asscalar() call.
Returns: - NDArray or float
Total norm. Return type is NDArray of shape (1,) if check_isfinite is False. Otherwise a float is returned.