View source on GitHub |
Wrapper allowing a stack of RNN cells to behave as a single cell.
tf.keras.layers.StackedRNNCells( cells, **kwargs )
Used to implement efficient stacked RNNs.
Arguments | |
---|---|
cells | List of RNN cell instances. |
batch_size = 3 sentence_max_length = 5 n_features = 2 new_shape = (batch_size, sentence_max_length, n_features) x = tf.constant(np.reshape(np.arange(30), new_shape), dtype = tf.float32) rnn_cells = [tf.keras.layers.LSTMCell(128) for _ in range(2)] stacked_lstm = tf.keras.layers.StackedRNNCells(rnn_cells) lstm_layer = tf.keras.layers.RNN(stacked_lstm) result = lstm_layer(x)
Attributes | |
---|---|
output_size | |
state_size |
get_initial_state
get_initial_state( inputs=None, batch_size=None, dtype=None )
© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.4/api_docs/python/tf/keras/layers/StackedRNNCells