The Sequential Network represents a sequence of Keras layers.
name: typing.Text = None
Used in the notebooks
It is a TF-Agents network that should be used instead of
tf.keras.layers.Sequential. In contrast to keras Sequential, this layer can be
used as a pure Layer in tf.functions and when exporting SavedModels, without
having to pre-declare input and output shapes. In turn, this layer is usable
as a preprocessing layer for TF Agents Networks, and can be exported via
Stateful Keras layers (e.g. LSTMCell, RNN, LSTM, TF-Agents DynamicUnroll)
are all supported. The
Sequential is a tuple whose
length matches the number of stateful layers passed. If no stateful layers
or networks are passed to
state_spec == ().
c = Sequential([layer1, layer2, layer3])
output, next_state = c(inputs, state)
A list or tuple of layers to compose. Any layers that
are subclasses of
(Optional.) A nest of
input observations to the first layer.
(Optional.) Network name.
layers is empty.
layers is a generic Keras layer (not a TF-Agents
input_spec is None.
If any of the layers are not instances of keras
; as this is required to
be able to create deep copies of layers in
Returns the spec of the input to the network of type InputSpec.
Get the list of all (nested) sub-layers used in this Network.
) -> "Sequential"
Make a copy of a
Note: A copy of a
Sequential instance always performs a deep copy
of the underlying layers, so the new instance will not share weights
with the original - but it will start with the same weights.
Args to override when recreating this network. Commonly
overridden args include 'name'.
A deep copy of this network.
Force creation of the network's variables.
Return output specs.
(Optional). Override or provide an input tensor spec
when creating variables.
Other arguments to
Output specs - a nested spec calculated from the outputs (excluding any
batch dimensions). If any of the output elements is a tfp
the associated spec entry returned is
input_tensor_spec is provided, and the network did
not provide one during construction.
Returns an initial state usable by the network.
Tensor or constant: size of the batch dimension. Can be None
in which case not dimensions gets added.
A nested object of type
self.state_spec containing properly
Retrieves a layer based on either its name (unique) or index.
index are both provided,
index will take precedence.
Indices are based on order of horizontal graph traversal (bottom-up).
String, name of layer.
Integer, index of layer.
A layer instance.
In case of invalid layer name or index.
line_length=None, positions=None, print_fn=None
Prints a string summary of the network.
Total length of printed lines
(e.g. set this to adapt the display to different
terminal window sizes).
Relative or absolute positions of log elements
in each line. If not provided,
[.33, .55, .67, 1.].
Print function to use. Defaults to
It will be called on each line of the summary.
You can set it to a custom function
in order to capture the string summary.
summary() is called before the model is built.