lck1201 opened a new issue #9291: find a bug in mxnet.gluon.utils.clip_global_norm(arrays, max_norm) URL: https://github.com/apache/incubator-mxnet/issues/9291 Find a bug in mxnet.gluon.utils.clip_global_norm(arrays, max_norm) ```python def clip_global_norm(arrays, max_norm): """Rescales NDArrays so that the sum of their 2-norm is smaller than `max_norm`. """ assert len(arrays) > 0 ctx = arrays[0].context total_norm = ndarray.add_n(*[ndarray.dot(x, x).as_in_context(ctx) for x in (arr.reshape((-1,)) for arr in arrays)]) total_norm = ndarray.sqrt(total_norm).asscalar() if not np.isfinite(total_norm): warnings.warn(UserWarning('nan or inf is detected. Clipping results will be undefined.'), stacklevel=2) scale = max_norm / (total_norm + 1e-8) if scale < 1.0: for arr in arrays: arr *= scale return total_norm ``` Perhaps the function should return **arrays** rather than **total_norm** Thx!
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services