You want to predict future values of a time series using a recurrent neural network. Which TensorFlow layer is best suited to capture long-term dependencies in the data?
Think about which layer can remember information over many time steps.
LSTM layers are designed to remember information for long sequences, making them ideal for time series prediction where long-term dependencies matter.
What is the output shape of the following TensorFlow code?
import tensorflow as tf model = tf.keras.Sequential([ tf.keras.layers.LSTM(10, input_shape=(5, 3)) ]) output_shape = model.output_shape
By default, LSTM returns the last output for each sample.
The LSTM layer with 10 units and input shape (5,3) returns output shape (None, 10) because it outputs the last time step's output for each batch sample.
You train an RNN on time series data with sequences of length 100. You reduce the sequence length to 10. What is the most likely effect on training?
Shorter sequences mean less data per sample but less context.
Reducing sequence length speeds up training because the model processes fewer time steps, but it may lose important long-term dependencies in the data.
You train an RNN to predict continuous values in a time series. Which metric is best to evaluate the model's performance?
Think about metrics for continuous value prediction.
Mean Squared Error measures the average squared difference between predicted and true values, making it suitable for regression tasks like time series forecasting.
You train an RNN on a long time series but notice the training loss becomes NaN after a few epochs. What is the most likely cause?
NaN loss often happens when gradients become too large.
Exploding gradients cause very large updates that make weights become NaN, leading to loss becoming NaN during training.