生活随笔
收集整理的這篇文章主要介紹了
TensorFlow学习笔记(十八)tf.reshape矩阵变形
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
tf.reshape(tensor, shape, name=None)
矩陣變形是常用的操作,在Tensorflow中調用方式有多種,例如:
1. tf.reshape
tf.reshape(L3,?[-1,?W4.get_shape().as_list()[0]])??
2. object.reshape
mnist.test.images.reshape(-1,?28,?28,?1)?
所有reshape函數中,關鍵的是shape這個參數
下以tf.reshape為例介紹shape參數對結果的影響
tf.reshape(tensor,?shape,?name=None)?
????reshape(t,?[3,?3])?==>?[[1,?2,?3],??????????????????????????[4,?5,?6],??????????????????????????[7,?8,?9]]????????????reshape(t,?[2,?4])?==>?[[1,?1,?2,?2],??????????????????????????[3,?3,?4,?4]]??????????????????????reshape(t,?[-1])?==>?[1,?1,?1,?2,?2,?2,?3,?3,?3,?4,?4,?4,?5,?5,?5,?6,?6,?6]??????????????reshape(t,?[2,?-1])?==>?[[1,?1,?1,?2,?2,?2,?3,?3,?3],???????????????????????????[4,?4,?4,?5,?5,?5,?6,?6,?6]]????reshape(t,?[-1,?9])?==>?[[1,?1,?1,?2,?2,?2,?3,?3,?3],???????????????????????????[4,?4,?4,?5,?5,?5,?6,?6,?6]]????reshape(t,?[?2,?-1,?3])?==>?[[[1,?1,?1],????????????????????????????????[2,?2,?2],????????????????????????????????[3,?3,?3]],???????????????????????????????[[4,?4,?4],????????????????????????????????[5,?5,?5],????????????????????????????????[6,?6,?6]]]??????????reshape(t,?[])?==>?7?
總結
以上是生活随笔為你收集整理的TensorFlow学习笔记(十八)tf.reshape矩阵变形的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。