tensorflow中的reshape(tensor,[1,-1])和reshape(tensor,[-1,1])

tf.reshape(tensor,[-1,1])將張量變爲一維列向量

tf.reshape(tensor,[1,-1])將張量變爲一維行向量

 

 

import tensorflow as tf
a = [[1,2],[3,4],[5,6]]
tf.reshape(a,[-1,1])
Out[13]: <tf.Tensor 'Reshape_4:0' shape=(6, 1) dtype=int32>
tf.reshape(tf.reshape(a,[-1,1]),[1,-1])
Out[14]: <tf.Tensor 'Reshape_6:0' shape=(1, 6) dtype=int32>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章