我有以下图像:
import tensorflow as tf
tf.enable_eager_execution()
tf.executing_eagerly()
img = Image.open('image.jpg')
try:
data = np.asarray(img, dtype='uint8' )
except SystemError:
data = np.asarray(img.getdata(), dtype='uint8' )
tf.shape(data)
<tf.Tensor: id=2, shape=(3,), dtype=int32, numpy=array([263, 320, 3], dtype=int32)>
image = tf.expand_dims(data, 0)
tf.shape(image)
<tf.Tensor: id=16, shape=(4,), dtype=int32, numpy=array([ 1, 263, 320, 3], dtype=int32)>
tf.squeeze(image, squeeze_dims=[0])
<tf.Tensor: id=22, shape=(263, 320, 3), dtype=uint8, numpy=...>
如何更换最后一个
tf.squeeze
使用类似的命令(例如:
tf.reshape
)?