Keras layers are the fundamental building block of keras models. Layers are created using a wide variety of
layer_ functions and are typically composed together by stacking calls to them using the pipe
%>% operator. For example:
A wide variety of layers are available, including:
All layers share the following properties:
layer$name — String, must be unique within a model.
layer$input_spec — List of input specifications. Each entry describes one required input: (ndim, dtype). A layer with
n input tensors must have an
input_spec of length
layer$trainable — Boolean, whether the layer weights will be updated during training.
layer$uses_learning_phase – Whether any operation of the layer uses
layer$input_shape — Input shape. Provided for convenience, but note that there may be cases in which this attribute is ill-defined (e.g. a shared layer with multiple input shapes), in which case requesting
input_shape will result in an error. Prefer using
layer$output_shape — Output shape. See above.
layer$inbound_nodes — List of nodes.
layer$outbound_nodes — List of nodes.
layer$output — Input/output tensor(s). Note that if the layer is used more than once (shared layer), this is ill-defined and will result in an error. In such cases, use
layer$output_mask — Same as above, for masks.
layer$trainable_weights — List of variables.
layer$non_trainable_weights — List of variables.
layer$weights — The concatenation of the lists trainable_weights and non_trainable_weights (in this order).
layer$constraints — Mapping of weights to constraints.
The following functions are available for interacting with layers:
Layer/Model weights as R arrays
Count the total number of scalars composing the weights.
Retrieve tensors for layers with multiple nodes
Reset the states for a layer