Albert G Lieu
Albert G Lieu

Reputation: 911

tf.keras.models.model vs tf.keras.model

Is the models redundant in tf.keras API? For some cases, even without using models, the code also runs well.

  1. keras.models.sequential and keras.sequential
  2. tf.keras.models.Model and tf.keras.Model

However, sometimes, models seems to be necessary. For example,
model = keras.models.load_model(), But model = keras.Model does not has .load_model() function. Because .load_model() is defined in tf.keras.Model.

I find it quite confusing and semi-redundant. Could anyone explain what is the point of models, and when it is necessary?

Upvotes: 4

Views: 2422

Answers (2)

ComputerScientist
ComputerScientist

Reputation: 964

This might be a little more intuitive and easier to read (though admittedly it depends on the accuracy of the documentation). Using the TensorFlow documentation, you can click on "view aliases" as I've done here in the below screenshot:

enter image description here

this will show that tf.keras.Model has tf.keras.models.Model as an alias. Therefore, they point to the same thing.

This is with TensorFlow 2.3.0 but should be similar for other prior 2.x versions.

Upvotes: 2

Ming.Xu
Ming.Xu

Reputation: 51

they are the same thing. all is from tensorflow.python.keras.engine.training import Model checkout: keras.init.py and keras.models.py

Upvotes: 0

Related Questions