Reputation: 911
Is the models
redundant in tf.keras API? For some cases, even without using models
, the code also runs well.
keras.models.sequential
and keras.sequential
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
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:
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
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