Pritam Shrestha
Pritam Shrestha

Reputation: 486

What is difference between tf.keras.models.sequential vs tf.keras.sequential?

What is difference between tf.keras.models.Sequential() vs tf.keras.Sequential()? I don't understand differences between them quite well. Can somebody explain it to me? I am new to TensorFlow but have some basic understanding on machine learning.

Upvotes: 6

Views: 4731

Answers (3)

João Vicente
João Vicente

Reputation: 72

tf.keras.models.Sequential

and

tf.keras.Sequential

Do the same thing but they are from different versions of tensorflow. By the documentation (TensorFlow 2.0), tf.keras.Sequential is the most recent way of called this function.

Upvotes: 4

Smart Manoj
Smart Manoj

Reputation: 5824

>>> tf.keras.models.Sequential==tf.keras.Sequential
True

Both are same as of TFv2. You could use the later.

Added in this commit.

Upvotes: 5

CAFEBABE
CAFEBABE

Reputation: 4101

Keras (keras.io) is a library which is available on its own. It specifies the high-level api. tf.keras (https://www.tensorflow.org/guide/keras) implements the Keras API specification within TensorFlow.

If you intend to stick to the Tensorflow implementation I would stick to tf.keras. Otherwise you have the advantage to be backend agnostic.

=====

update for updated question.

The renaming of the package for tf.keras.models.Sequential to tf.keras.Sequential must have happened from 1.15 to 2.x you can either downgrade your tensor flow version or update the code. I'd go for the latter

Upvotes: 1

Related Questions