最近壓力好大,寫點東西可能對心情有好處。
reshape即把矩陣的形狀變一下,這跟matlab一樣的,但如果參數是-1的話是什么意思呢?
看一下例子哈:
In [21]:
tensor = tf.constant([1, 2, 3, 4, 5, 6, 7,8])
In [22]:
sess.run(tf.initialize_all_variables())
In [23]:
print(sess.run(tensor))
In [24]:
tensorReshape = tf.reshape(tensor,[2,4])
In [26]:
tensorReshape = tf.reshape(tensor,[1,2,4])
In [27]:
print(sess.run(tensorReshape))
In [28]:
tensorReshape = tf.reshape(tensor,[-1,2,2])
In [29]:
print(sess.run(tensorReshape))
