現在我通過這些方法將影像 (32,32) 更改為 (32,32,1)
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
img = np.expand_dims(img, axis=-1)
img = img.astype(np.float32)/255
img = tf.image.resize(img, [32,32])
但是現在,我想從 (32,32,1) 更改為 (1,32,32,1),所以我嘗試使用
img = img.reshape(1,32,32,1)
但是,它顯示'EagerTensor' object has no attribute 'reshape'.那么我可以使用什么其他方法?
uj5u.com熱心網友回復:
嘗試:
img = tf.random.normal((64, 64, 1))
img = tf.image.resize(img, [32,32])
img = tf.reshape(img, (1,32,32,1))
或者
img = tf.expand_dims(img, axis=0)
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/377828.html
