1. 报错信息如下
报错如下:
AttributeError Traceback (most recent call last)
<ipython-input-48-3f129f8c1fc2> in <module>
----> 1 iterator = tf.data.Iterator.from_structure(dataset_image.output_types, dataset_image.output_shapes)
2 real_image_batch, wrong_image_batch = iterator.get_next()
AttributeError: module 'tensorflow_core._api.v2.data' has no attribute 'Iterator'
2 . 解决办法
将报错代码
iterator = tf.data.Iterator.from_structure(dataset_image.output_types, dataset_image.output_shapes)
改为如下形式:
iterator = tf.compat.v1.data.Iterator.from_structure(tf.compat.v1.data.get_output_types(dataset_image),
tf.compat.v1.data.get_output_shapes(dataset_image))