MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Sequential

Class Sequential

tensorflow/python/keras/engine/sequential.py:40–382  ·  view source on GitHub ↗

Linear stack of layers. Arguments: layers: list of layers to add to the model. Example: ```python # Optionally, the first layer can receive an `input_shape` argument: model = Sequential() model.add(Dense(32, input_shape=(500,))) # Afterwards, we do automatic shape inference:

Source from the content-addressed store, hash-verified

38
39@keras_export('keras.models.Sequential', 'keras.Sequential')
40class Sequential(training.Model):
41 """Linear stack of layers.
42
43 Arguments:
44 layers: list of layers to add to the model.
45
46 Example:
47
48 ```python
49 # Optionally, the first layer can receive an `input_shape` argument:
50 model = Sequential()
51 model.add(Dense(32, input_shape=(500,)))
52 # Afterwards, we do automatic shape inference:
53 model.add(Dense(32))
54
55 # This is identical to the following:
56 model = Sequential()
57 model.add(Dense(32, input_dim=500))
58
59 # And to the following:
60 model = Sequential()
61 model.add(Dense(32, batch_input_shape=(None, 500)))
62
63 # Note that you can also omit the `input_shape` argument:
64 # In that case the model gets built the first time you call `fit` (or other
65 # training and evaluation methods).
66 model = Sequential()
67 model.add(Dense(32))
68 model.add(Dense(32))
69 model.compile(optimizer=optimizer, loss=loss)
70 # This builds the model for the first time:
71 model.fit(x, y, batch_size=32, epochs=10)
72
73 # Note that when using this delayed-build pattern (no input shape specified),
74 # the model doesn't have any weights until the first call
75 # to a training/evaluation method (since it isn't yet built):
76 model = Sequential()
77 model.add(Dense(32))
78 model.add(Dense(32))
79 model.weights # returns []
80
81 # Whereas if you specify the input shape, the model gets built continuously
82 # as you are adding layers:
83 model = Sequential()
84 model.add(Dense(32, input_shape=(500,)))
85 model.add(Dense(32))
86 model.weights # returns list of length 4
87
88 # When using the delayed-build pattern (no input shape specified), you can
89 # choose to manually build your model by calling `build(batch_input_shape)`:
90 model = Sequential()
91 model.add(Dense(32))
92 model.add(Dense(32))
93 model.build((None, 500))
94 model.weights # returns list of length 4
95 ```
96 """
97

Callers 4

testKerasModelMethod · 0.90
_clone_sequential_modelFunction · 0.50

Calls

no outgoing calls

Tested by 3

testKerasModelMethod · 0.72