tensorflow中squeeze与expand_dims
生活随笔
收集整理的這篇文章主要介紹了
tensorflow中squeeze与expand_dims
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
tf.squeeze
- z = tf.squeeze(y) #刪除y中所有為1的維度;
- z = tf.squeeze(y,[3,5]) #刪除[3,5]中所有為1的維度;
tf.expand_dims
- tf中沒有tf.unsqueeze,一般寫tf.expand_dims()擴增維度;
- one_img = tf.expand_dims(one_img, 0) #第0維插入1維
- one_img = tf.expand_dims(one_img, -1) #-1表示最后一維
總結
以上是生活随笔為你收集整理的tensorflow中squeeze与expand_dims的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: pytorch保存模型pth_浅谈pyt
- 下一篇: POJ 1033--Defragment