0

I have run:

loaded_model = tf.keras.models.load_model('/content/drive/MyDrive/Urdu-Ocr/model_pb/')

and then want to see model summary by using:

print(loaded_model.summary())

but it gives:

AttributeError: 'AutoTrackable' object has no attribute 'summary'

Working with tensorflow 1.15.2 on google colab.

maryam mehboob
  • 338
  • 5
  • 17
  • `tf.keras.models.load_model` only works with SavedModels saved from Keras. Suspecting saved model is saved with other api i.e., other than keras. Make sure use `tf.keras` api to save and load the model –  Jul 12 '21 at 06:16

1 Answers1

0

As seen from this Stack Overflow Answer, your Model might be a Frozen Model or a Check Point File.

Please refer the below comment which is taken from this Stack Overflow Answer:

You will have to rewrite that model's code in Keras. Then, you will have to read the values of your variables from the checkpoint file and assign it to Keras model using layer.load_weights(weights) method.

More than this methodology, I would suggest to you to do the training directly in Keras as it claimed that Keras' optimizers are 5-10% times faster than Tensorflow's optimizers. Other way is to write your code in Tensorflow with tf.contrib.keras module and save the file directly in hdf5 format.