此代码主要基于TF指南Load images with ^{
这是修改后的colab错误。在
代码的第一个更改是无害的:
# resize is moved to be an argument
def preprocess_image(image, resize=[192, 192]):
image = tf.image.decode_jpeg(image, channels=3)
image = tf.image.resize(image, resize)
image /= 255.0 # normalize to [0,1] range
return image
# argument bubbled up
def load_and_preprocess_image(path, resize=[192, 192]):
image = tf.read_file(path)
return preprocess_image(image, resize)
下一个变化是引入问题的地方:
^{2}$我怎么才能避开这个?tf.numpy_function
没有特定定义形状的参数,tf.data.Dataset
的属性output_shapes
是只读的
尝试使用变形就在那之后tf.numpy_函数重新初始化形状。在
相关问题 更多 >
编程相关推荐