AttributeError: у объекта 'KerasTPUModel' нет атрибута '_run_eagerly' - PullRequest
0 голосов
/ 17 июня 2019

Я использую tf.kaeras в google colab с ноутбуком python3.0 и получаю сообщение об ошибке со следующим кодом:

model = tf.keras.Model(inputs=[Inp], outputs=[output])

tpu_model = tf.contrib.tpu.keras_to_tpu_model(
    model,
    strategy=tf.contrib.tpu.TPUDistributionStrategy(
        tf.contrib.cluster_resolver.TPUClusterResolver(
            tpu='grpc://' + os.environ['COLAB_TPU_ADDR'])
    )
)

tpu_model.fit(
  train_input_fn,
  steps_per_epoch = 60,
  epochs=epochs)

И сообщение об ошибке

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-11-d6a0cf977e09> in <module>()
      2   train_input_fn,
      3   steps_per_epoch = 60,
----> 4   epochs=epochs)
      5 
      6 score = tpu_model.evaluate(x_test, y_test, verbose=0)

3 frames
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py in run_eagerly(self)
    399       Boolean, whether the model should run eagerly.
    400     """
--> 401     if self._run_eagerly is True and not context.executing_eagerly():
    402       raise ValueError('You can only set `run_eagerly=True` if eager execution '
    403                        'is enabled.')

AttributeError: 'KerasTPUModel' object has no attribute '_run_eagerly'

INFO:

Я получаю эту ошибку в Google Colab. Вот версия Python и tenorflow.

import sys
import tensorflow as tf
print("Python Version:", sys.version_info)
print("TensorFlow Version:", tf.__version__)

Версия Python: sys.version_info (major = 3, minor = 6, micro = 7, releaselevel = 'final', serial = 0) Версия TensorFlow: 1.14.0-rc1

...