Optional
batchIf defined, will be used to create an input layer to insert before this
layer. If both inputShape
and batchInputShape
are defined,
batchInputShape
will be used. This argument is only applicable to input
layers (the first layer of a model).
Optional
batchIf inputShape
is specified and batchInputShape
is not specified,
batchSize
is used to construct the batchInputShape
: [batchSize, ...inputShape]
Optional
dtypeThe data-type for this layer. Defaults to 'float32'. This argument is only applicable to input layers (the first layer of a model).
Optional
goIf true
, process the input sequence backwards and return the reversed
sequence (default: false
).
Optional
inputDTypeLegacy support. Do not use for new code.
Optional
inputDimensionality of the input (integer).
This option (or alternatively, the option inputShape
) is required when
this layer is used as the first layer in a model.
Optional
inputLength of the input sequences, to be specified when it is constant.
This argument is required if you are going to connect Flatten
then
Dense
layers upstream (without it, the shape of the dense outputs cannot
be computed). Note that if the recurrent layer is not the first layer in
your model, you would need to specify the input length at the level of the
first layer (e.g., via the inputShape
option).
Optional
inputIf defined, will be used to create an input layer to insert before this
layer. If both inputShape
and batchInputShape
are defined,
batchInputShape
will be used. This argument is only applicable to input
layers (the first layer of a model).
Optional
nameName for this layer.
Optional
returnWhether to return the last output in the output sequence, or the full sequence.
Optional
returnWhether to return the last state in addition to the output.
Optional
statefulIf true
, the last state for each sample at index i in a batch will be
used as initial state of the sample of index i in the following batch
(default: false
).
You can set RNN layers to be "stateful", which means that the states computed for the samples in one batch will be reused as initial states for the samples in the next batch. This assumes a one-to-one mapping between samples in different successive batches.
To enable "statefulness":
stateful: true
in the layer constructor.batchInputShape: [...]
to the first layer in your model.batchShape: [...]
to all the first layers in your model.
This is the expected shape of your inputs
including the batch size.
It should be a tuple of integers, e.g., [32, 10, 100]
.shuffle: false
when calling LayersModel.fit()
.To reset the state of your model, call resetStates()
on either the
specific layer or on the entire model.
Optional
trainableWhether the weights of this layer are updatable by fit
.
Defaults to true.
Optional
unrollIf true
, the network will be unrolled, else a symbolic loop will be
used. Unrolling can speed up a RNN, although it tends to be more
memory-intensive. Unrolling is only suitable for short sequences (default:
false
).
Porting Note: tfjs-layers has an imperative backend. RNNs are executed with
normal TypeScript control flow. Hence this property is inapplicable and
ignored in tfjs-layers.
Optional
weightsInitial weight values of the layer.
Generated using TypeDoc
RNNLayerConfig is identical to BaseRNNLayerConfig, except it makes the
cell
property required. This interface is to be used with constructors of concrete RNN layer subtypes.