Tensorflow基础7:形状的重设

Tensorflow

基础7:形状的重设

numpy当中reshape可以进行形状的调整
tf中分为静态和动态形状: ts.get_shape:获取形状
tf.reshape():重设形状

with one.as_default():
    plh = tf.placeholder(dtype='int32',shape=[3,3,3])
    a = tf.constant(np.random.randint(0,100,(2,2,2)))
with tf.Session(graph=one) as sess:
    plh_reshape = tf.reshape(plh,[9,3])
    print(sess.run(plh_reshape,feed_dict={plh_reshape:np.random.randint(0,10,(9,3))}))    
    print(a.get_shape())

[[8 8 9]
[5 3 5]
[4 8 1]
[7 8 2]
[1 2 1]
[4 2 2]
[8 8 9]
[6 9 3]
[7 6 9]]
(2, 2, 2)