![]() |
Class Sequential
Represents a linear sequence of Layers or functions.
Inherits From: Network
The output of each layer/function is provided as the input to the next.
The inputs passed to __call__
are passed to the inputs of the first
Layer, and it returns the outputs of the last Layer.
Args:
layers_funcs
: An optional sequence where each element is either a tf.compat.v1.layers.Layer object or a callable.name
: An optional string name to use for this Network.
__init__
__init__(
layers_funcs=None,
name=None
)
Configure the Network
. (deprecated)
tf.keras.Model
works with all TensorFlow Layer
instances, including those from tf.layers
, but switching to the tf.keras.layers
versions along with the migration to tf.keras.Model
is recommended, since it will preserve variable names. Feel free to import it with an alias to avoid excess typing :).
Args:
name
: The name to use for thisNetwork
. If specified, it must be unique in the context where thisNetwork
is first (1) added to anotherNetwork
(in which case it must not share a name with otherLayers
added to thatNetwork
), or (2) built/called (in which case no other 'top-level'Network
s may share this name). If unspecified or None, theNetwork
will be named using its class name, with a number appended if necessary for uniqueness (e.g. MyNetwork -> 'my_network_1').
Raises:
ValueError
: Ifname
is not valid. Note that some naming errors will instead be raised when theNetwork
is called.
Properties
graph
DEPRECATED FUNCTION
layers
scope_name
Methods
tf.contrib.eager.Sequential.add
add(layer_func)
tf.contrib.eager.Sequential.get_layer
get_layer(
name=None,
index=None
)
Get a contained tf.compat.v1.layers.Layer
either by name or index.
Args:
name
: String matching one of the names of a containedLayer
. Note that the names ofLayer
s added toNetwork
s may not be unique when doing layer sharing (i.e. adding aLayer
to thisNetwork
which was already added to anotherNetwork
). The lowest indexLayer
with a matching name will be returned.index
: Integer in [0, number of layers). Layers are assigned an index by the order they are added.
Returns:
A tf.compat.v1.layers.Layer
object.
Raises:
ValueError
: If neither or both of 'index' or 'name' is specified, or the lookup failed.
tf.contrib.eager.Sequential.track_layer
track_layer(layer)
Track a Layer in this Network.
Network
requires that all Layer
s used in call()
be tracked so that the
Network
can export a complete list of variables.
Args:
layer
: Atf.compat.v1.layers.Layer
object.
Returns:
The passed in layer
.
Raises:
RuntimeError
: If init has not been called.TypeError
: Iflayer
is the wrong type.ValueError
: If aLayer
with the same name has already been added.