tensorflow: tf.keras becuase Tensorflow Version Update to 1.14.0 Not Running

Tensorflow Version: 1.14.0 Exception :

---------------------------------------------------------------------------

AttributeError                            Traceback (most recent call last)

<ipython-input-14-dcf9102c1887> in <module>()
----> 1 trainModel()

3 frames

/usr/local/lib/python3.6/dist-packages/tensorflow/contrib/tpu/python/tpu/keras_support.py in __init__(self, cpu_model, strategy)
   1426           self._cpu_model.sample_weight_mode,
   1427           self._cpu_model._compile_weighted_metrics,
-> 1428           self._cpu_model.target_tensors,
   1429       )
   1430 

AttributeError: 'Model' object has no attribute 'target_tensors'

But My Code in Tensorflow Version 1.13.1 is Normal Working.

My Code:

···
	tuneModel = Model(inputs=base_model.input, outputs = output)
	tuneModel.compile(loss='sparse_categorical_crossentropy', optimizer= tf.train.RMSPropOptimizer(learning_rate=1e-4) ,metrics=['accuracy'])

···

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 23 (4 by maintainers)

Most upvoted comments

I made it work by instead of using tf.contrib.tpu.keras_to_tpu_model, I created the model within the TPU strategy scope.

Thank You rzilleruelo,This way i have try.But tips NotImplementedError: `fit_generator` is not supported for models compiled with tf.distribute.Strategy.

There are some examples of code for TPUs here: https://github.com/tensorflow/tpu/tree/master/models/experimental. Cheers.

Edit: it’s also possible in Colab to revert to an earlier version by running

%pip install tensorflow==1.13.1

and then resetting your run time.