error如下:
File "D:\python\lib\site-packages\tensorflow_core\python\framework\ops.py", line 547, in __iter__
self._disallow_iteration()
File "D:\python\lib\site-packages\tensorflow_core\python\framework\ops.py", line 543, in _disallow_iteration
self._disallow_in_graph_mode("iterating over `tf.Tensor`")
File "D:\python\lib\site-packages\tensorflow_core\python\framework\ops.py", line 523, in _disallow_in_graph_mode
" this function with @tf.function.".format(task))
tensorflow.python.framework.errors_impl.OperatorNotAllowedInGraphError: iterating over `tf.Tensor` is not allowed in Graph execution. Use Eager execution or decorate this function with @tf.function.
发现在前面加入
tf.compat.