AttributeError:“ KerasTPUModel”对象没有属性“ _run_eagerly”

时间:2019-06-17 02:09:49

标签: tensorflow keras tf.keras

我在带有python3.0笔记本的google colab中使用 tf.kaeras ,并通过以下代码获取错误:

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'

信息:

我在google colab中收到此错误。这是Python和tensorflow版本。

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

Python版本:sys.version_info(主要= 3,次要= 6,微型= 7,发布级别=“最终”,序列= 0)   TensorFlow版本:1.14.0-rc1

0 个答案:

没有答案