最近压力好大,写点东西可能对心情有好处。
reshape即把矩阵的形状变一下,这跟matlab一样的,但如果参数是-1的话是什么意思呢?
看一下例子哈:
tensor = tf.constant([1, 2, 3, 4, 5, 6, 7,8])
sess.run(tf.initialize_all_variables())
print(sess.run(tensor))
tensorReshape = tf.reshape(tensor,[2,4])
tensorReshape = tf.reshape(tensor,[1,2,4])
print(sess.run(tensorReshape))
tensorReshape = tf.reshape(tensor,[-1,2,2])
print(sess.run(tensorReshape))
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:tensorflow 之 tf.reshape 之 -1 - Python技术站