module 'tensorflow._api.v1.image' has no attribute 'resize' 报错解决
TensorFlow版本兼容问题,1.x和2版本部分函数不同。
目前适用版本TensorFlow1.12
image = tf.image.resize(image, [28, 28])
报错:module ‘tensorflow._api.v1.image’ has no attribute ‘resize’ 。
改成tf.image.resize_bilinear数据维度报错,后改成:
image = tf.image.resize_images(image, [28, 28],align_corners=True)
成功!
附 tf.image.resize_bilinear()、()2个函数的介绍。
- tf.image.resize_bilinear()
tf.image.resize_bilinear(
images,
size,
align_corners=False,
name=None
)
使用双线性插值调整images为size。输入图像可以是不同的类型,但输出图像总是浮点型的。
参数:
images:一个Tensor,必须是下列类型之一:int8,uint8,int16,uint16,int32,int64,bfloat16,half,float32,float64;4维的并且具有形状[batch, height, width, channels]。
size:2个元素(new_height, new_width)的1维int32张量,用来表示图像的新大小。
align_corners:可选的bool,默认为False;如果为True,则输