当前位置:   article > 正文

__iter__() is only supported inside of tf.function or when eager execution is enabled

__iter__() is only supported inside of tf.function or when eager execution i

运行tensorflow代码出现这个

__iter__() is only supported inside of tf.function or when eager execution is enabled

 按照字面意思就是需要增加eager execution,于是这样进行修改:

  1. import tensorflow.contrib.eager as tfe
  2. tfe.enable_eager_execution()

但会出现错误:

AttributeError: module 'tensorflow.contrib.eager' has no attribute 'enable_eager_execution'

 在github里面看到有人遇到过这个问题,实际是版本的锅,这样就ok

  1. import tensorflow as tf
  2. tf.enable_eager_execution()

注:我使用的是tensorflow1.15

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号