tensorflow中squeeze与expand_dims
生活随笔
收集整理的這篇文章主要介紹了
tensorflow中squeeze与expand_dims
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
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()擴(kuò)增維度;
- one_img = tf.expand_dims(one_img, 0) #第0維插入1維
- one_img = tf.expand_dims(one_img, -1) #-1表示最后一維
總結(jié)
以上是生活随笔為你收集整理的tensorflow中squeeze与expand_dims的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: pytorch保存模型pth_浅谈pyt
- 下一篇: POJ 1033--Defragment