tensorflow1.X矩阵维数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import tensorflow as tf

a = tf.Variable(10,name='0d')
b = tf.Variable([10,10,10],name='1d')
c = tf.Variable([[10,10,10],
[10,10,10]],name='2d')

print(a.shape)
#()

print(b.shape)
#(3,)

print(c.shape)
#(2, 3)

#套括号的作用
a1 = tf.Variable([10],name='n0d')
b1 = tf.Variable([[10,10,10]],name='n1d')

print(a1.shape)
#(1,)

print(b1.shape)
#(1,3)

转载请注明来源 https://tianweiye.github.io