Sequential
keras.layers.containers.Sequential(layers=[])
The Sequential container is a linear stack of layers.
Apart from the add
methods and the layers
constructor argument,
the API is identical to that of the Layer
class.
This class is also the basis for the keras.models.Sequential
model.
Arguments
- layers: list of layers to be added to the container.
Methods
add(layer)
reset_states()
set_input()
clear_previous(reset_weights=True)
Defined by Layer.
count_params()
Defined by Layer.
get_config()
Defined by Layer.
get_input(train=False)
Defined by Layer.
get_output(train=False)
Defined by Layer.
get_output_mask(train=None)
Defined by Layer.
get_weights()
Defined by Layer.
set_input_shape(input_shape)
Defined by Layer.
set_previous(layer, reset_weights=True)
Defined by Layer.
set_weights(weights)
Defined by Layer.
supports_masked_input()
Defined by Layer.
Graph
keras.layers.containers.Graph()
Implement a NN graph with arbitrary layer connections, arbitrary number of inputs and arbitrary number of outputs.
This class is also the basis for the keras.models.Graph
model.
- Note:
Graph
can only be used as a layer (connect, input, get_input, get_output) when it has exactly one input and one output.
Methods
add_input(name, input_shape=None, batch_input_shape=None, dtype='float')
Add an input to the graph.
-
_Arguments_:
-
name: string. The name of the new input. Must be unique in the graph.
- input_shape: a tuple of integers, the expected shape of the input samples. Does not include the batch size.
- batch_input_shape: a tuple of integers, the expected shape of the whole input batch, including the batch size.
- dtype: 'float' or 'int'.
add_node(layer, name, input=None, inputs=[], merge_mode='concat', concat_axis=-1, dot_axes=-1, create_output=False)
Add a node in the graph. It can be connected to multiple inputs, which will first be merged into one tensor according to the mode specified.
Arguments
- layer: the layer at the node.
- name: name for the node.
- input: when connecting the layer to a single input, this is the name of the incoming node.
- inputs: when connecting the layer to multiple inputs, this is a list of names of incoming nodes.
- merge_mode: one of {concat, sum, dot, ave, mul}
- concat_axis: when
merge_mode=='concat'
, this is the input concatenation axis. - dot_axes: when
merge_mode='dot'
, this is the contraction axes specification; see the `Merge layer for details. - create_output: boolean. Set this to
True
if you want the output of your node to be an output of the graph.
add_output(name, input=None, inputs=[], merge_mode='concat', concat_axis=-1, dot_axes=-1)
Add an output to the graph.
This output can merge several node outputs into a single output.
Arguments
- name: name of the output.
- input: when connecting the layer to a single input, this is the name of the incoming node.
- inputs: when connecting the layer to multiple inputs, this is a list of names of incoming nodes.
- merge_mode: one of {concat, sum, dot, ave, mul}
- concat_axis: when
merge_mode=='concat'
, this is the input concatenation axis. - dot_axes: when
merge_mode='dot'
, this is the contraction axes specification; see the `Merge layer for details.
add_shared_node(layer, name, inputs=[], merge_mode=None, concat_axis=-1, dot_axes=-1, outputs=[], create_output=False)
Used to share a same layer across multiple nodes.
Supposed, for instance, that you want to apply one same Dense
layer after to the output of two different nodes.
You can then add the Dense
layer as a shared node.
Arguments
- layer: The layer to be shared across multiple inputs
- name: Name of the shared node
- inputs: List of names of input nodes
- merge_mode: Same meaning as
merge_mode
argument ofadd_node()
- concat_axis: Same meaning as
concat_axis
argument ofadd_node()
- dot_axes: Same meaning as
dot_axes
argument ofadd_node()
- outputs: Used when
merge_mode=None
. Names for the output nodes. - create_output: Same meaning as
create_output
argument ofadd_node()
.
reset_states()
clear_previous(reset_weights=True)
Defined by Layer.
count_params()
Defined by Layer.
get_config()
Defined by Layer.
get_input(train=False)
Defined by Layer.
get_output(train=False)
Defined by Layer.
get_output_mask(train=None)
Defined by Layer.
get_weights()
Defined by Layer.
set_input_shape(input_shape)
Defined by Layer.
set_previous(layer, connection_map={}, reset_weights=True)
Defined by Layer.
set_weights(weights)
Defined by Layer.
supports_masked_input()
Defined by Layer.