Colab最近更新导致错误:仅在启用急切执行时,张量对象才可迭代

时间:2019-06-15 01:09:13

标签: tensorflow google-colaboratory eager-execution

我有一个受https://github.com/kyzhouhzau/BERT-NER启发的google Colab笔记本,在几个月前效果很好。

现在它在在线训练期间失败了

estimator.train(input_fn=train_input_fn, max_steps=num_train_steps)

出现错误消息:

TypeError                                 Traceback (most recent call last)
<ipython-input-106-a57b458e486b> in <module>()
     54       is_training=True,
     55       drop_remainder=True)
---> 56   estimator.train(input_fn=train_input_fn, max_steps=num_train_steps)
     57 
     58   #evaluate

14 frames
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py in __iter__(self)
    475     if not context.executing_eagerly():
    476       raise TypeError(
--> 477           "Tensor objects are only iterable when eager execution is "
    478           "enabled. To iterate over this tensor use tf.map_fn.")
    479     shape = self._shape_tuple()

TypeError: Tensor objects are only iterable when eager execution is enabled. To iterate over this tensor use tf.map_fn.

我尝试添加:     tf.enable_eager_execution()

强制执行急切的操作,但没有帮助

我认为有关库的更新可能是导致此问题的原因。它曾经在tensorflow 1.13.1和bert-tensorflow-1.0.1(来自bert-tensorflow)(1.11.0)上工作。

现在使用tensorflow 1.14.0-rc1和bert-tensorflow-1.0.1(来自bert-tensorflow)(1.12.0)。

任何有关如何解决此问题的建议将不胜感激! 谢谢

0 个答案:

没有答案