0

I have a google Colab notebook inspired from https://github.com/kyzhouhzau/BERT-NER that worked perfectly fine a couple of months ago.

Now it fails during training at the line

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

With the error message:

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.

I tried adding: tf.enable_eager_execution()

to force eager execution but it did not help

I'm thinking an update on libraries may be causing the issue. It used to work on tensorflow 1.13.1 and bert-tensorflow-1.0.1 (from bert-tensorflow) (1.11.0).

Now it's using tensorflow 1.14.0-rc1 and bert-tensorflow-1.0.1 (from bert-tensorflow) (1.12.0).

Any advice on how to address this would be greatly appreciated! Thanks

yoann
  • 311
  • 5
  • 17
  • 1
    You can install TensorFlow 1.13.1 in Colab and see if it is working. If it works in the older version, then refer to the latest docs which explain the changes in the new releases. – Shubham Panchal Jun 15 '19 at 04:11
  • Thanks for your suggestion @ShubhamPanchal. I tried it with !pip install tensorflow-gpu==1.13.1, it showed an error "ERROR: tensorflow 1.14.0rc1 has requirement tensorflow-estimator<1.15.0rc0,>=1.14.0rc0, but you'll have tensorflow-estimator 1.13.0 which is incompatible.". The code is running but still showing the same error eventually (with or without eager mode enabled) – yoann Jun 15 '19 at 13:27

0 Answers0