def max_norm_all_tensors(tensor_list, clip: bool = True):
"""Normalization of list of tensors by maximum of tensors"""
maxima = [tf.reduce_max(tf.abs(tensor)) for tensor in tensor_list]
maxima = tf.stack(maxima)
if clip:
maximum = tf.reduce_max(maxima) + 1e-16
else:
maximum = tf.reduce_max(maxima)
return [tf.divide(tensor, maximum) for tensor in tensor_list]
normalizations.py 文件源码
python
阅读 37
收藏 0
点赞 0
评论 0
评论列表
文章目录