tf.nn.softmax的axis的理解

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/guotong1988/article/details/82914064
import tensorflow as tf
tf.enable_eager_execution()
ones = tf.ones(shape=[2,3])
temp1 = tf.nn.softmax(ones,axis=0) # 列
print(temp1)
temp2 = tf.nn.softmax(ones,axis=1) # 行
print(temp2)

打印结果:

tf.Tensor(
[[0.5 0.5 0.5]
[0.5 0.5 0.5]], shape=(2, 3), dtype=float32)
tf.Tensor(
[[0.33333334 0.33333334 0.33333334]
[0.33333334 0.33333334 0.33333334]], shape=(2, 3), dtype=float32)

猜你喜欢

转载自blog.csdn.net/guotong1988/article/details/82914064