axis = x就是在第x维扩展,直接用例子来演示
current = np.array([
[0, 7, 1, 2, 2],
[1, 7, 3, 4, 3],
[2, 7, 5, 6, 6],
[3, 7, 7, 8, 7],
[4, 7, 7, 8, 7],
[5, 7, 7, 8, 7]
])
current = array(current)
current = tf.constant(current)
points_e0 = tf.expand_dims(current, axis=0)
points_e1 = tf.expand_dims(current, axis=1)
points_e2 = tf.expand_dims(current, axis=2)
with tf.Session() as sess :
print(points_e0.eval())
print(points_e1.eval())
print(points_e2.eval())
输出结果
[[[0 7 1 2 2]
[1 7 3 4 3]
[2 7 5 6 6]
[3 7 7 8 7]
[4 7 7 8 7]
[5 7 7 8 7]]]
[[[0 7 1 2 2]]
[[1 7 3 4 3]]
[[2 7 5 6 6]]
[[3 7 7 8 7]]
[[4 7 7 8 7]]
[[5 7 7 8 7]]]
[[[0]
[7]
[1]
[2]
[2]]
[[1]
[7]
[3]
[4]
[3]]
[[2]
[7]
[5]
[6]
[6]]
[[3]
[7]
[7]
[8]
[7]]
[[4]
[7]
[7]
[8]
[7]]
[[5]
[7]
[7]
[8]
[7]]]