Tensorflow error(一):__iter__() is only supported when eager execution is enabled.

Tensorflow error(一):__iter__() is only supported when eager execution is enabled._第1张图片
错误语句:RuntimeError: iter() is only supported inside of tf.function or when eager execution is enabled.

解决方法:I fixed it by enabling eager execution after importing tensorflow:

import tensorflow as tf
 
tf.enable_eager_execution()

转载:
https://stackoverflow.com/questions/55576133/tensorflow-2-0-dataset-iter-is-only-supported-when-eager-execution-is-enab?noredirect=1&lq=1

你可能感兴趣的:(#,Tensorflow,python,tensorflow)