t = tf.constant([[1,2,3],[4,5,6]])
>>> k = tf.reduce_mean(t, axis=0)
>>> with tf.Session() as sess:
print(k.eval())
[2 3 4]
可以看出axis=0时,是行方向的缩减
而在tf.clip_by_norm函数中也是一样的,手册是这样写的:
As another example, if t
is a matrix and axes == [1]
, then each row of the output will have L2-norm equal to clip_norm
. If axes == [0]
instead, each column of the output will be clipped.
即当axes为0的时候,对一整列求L2最大L2惩罚,在行方向上放缩。