Complete the code to add an LSTM layer with 50 units to the model.
model.add(tf.keras.layers.LSTM([1]))The LSTM layer requires the number of units as an integer. Here, 50 units are specified.
Complete the code to define the input shape for the LSTM layer with 100 time steps and 20 features.
model.add(tf.keras.layers.LSTM(64, input_shape=[1]))
The input_shape for LSTM is a tuple (timesteps, features). Here, 100 time steps and 20 features are correct.
Fix the error in the code by completing the LSTM layer to return sequences for stacking.
model.add(tf.keras.layers.LSTM(32, return_sequences=[1]))
Setting return_sequences=True makes the LSTM output a sequence, which is needed when stacking LSTM layers.
Fill both blanks to create a stacked LSTM model with 64 units in the first layer returning sequences, and 32 units in the second layer.
model = tf.keras.Sequential() model.add(tf.keras.layers.LSTM([1], return_sequences=[2], input_shape=(50, 10))) model.add(tf.keras.layers.LSTM(32))
The first LSTM layer has 64 units and must return sequences (True) to feed the next LSTM layer.
Fill all three blanks to build a model with an LSTM layer of 100 units, dropout rate 0.2, and a Dense output layer with 1 unit.
model = tf.keras.Sequential([
tf.keras.layers.LSTM([1], dropout=[2], input_shape=(30, 5)),
tf.keras.layers.Dense([3])
])The LSTM layer has 100 units with dropout 0.2, and the Dense layer outputs 1 unit for prediction.