Challenge - 5 Problems
SimpleRNN Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output shape of SimpleRNN layer
What is the output shape of the following SimpleRNN layer when given input shape (batch_size=32, timesteps=10, features=8)?
TensorFlow
import tensorflow as tf rnn = tf.keras.layers.SimpleRNN(16) input_shape = (32, 10, 8) inputs = tf.random.uniform(input_shape) outputs = rnn(inputs) print(outputs.shape)
Attempts:
2 left
💡 Hint
SimpleRNN by default returns only the last output for each sequence.
✗ Incorrect
The SimpleRNN layer with units=16 returns the last output for each sequence, so the output shape is (batch_size, units) = (32, 16).
❓ Model Choice
intermediate1:30remaining
Choosing SimpleRNN for sequence data
Which of the following tasks is best suited for a SimpleRNN layer?
Attempts:
2 left
💡 Hint
SimpleRNN is designed to process sequences over time.
✗ Incorrect
SimpleRNN is a recurrent layer that processes sequences, making it suitable for tasks like predicting the next word in a sentence.
❓ Hyperparameter
advanced1:30remaining
Effect of return_sequences=True in SimpleRNN
What is the effect of setting return_sequences=True in a SimpleRNN layer?
Attempts:
2 left
💡 Hint
Think about whether the output includes all timesteps or just the last one.
✗ Incorrect
Setting return_sequences=True makes SimpleRNN return the output at every timestep, resulting in a 3D tensor (batch_size, timesteps, units).
❓ Metrics
advanced1:30remaining
Interpreting training loss for SimpleRNN model
A SimpleRNN model for sequence classification shows training loss decreasing steadily but validation loss increasing after some epochs. What does this indicate?
Attempts:
2 left
💡 Hint
Think about what it means when training loss improves but validation loss worsens.
✗ Incorrect
When training loss decreases but validation loss increases, the model is learning training data too well and not generalizing, which is overfitting.
🔧 Debug
expert2:30remaining
Debugging SimpleRNN input shape error
Given this code snippet, what error will occur and why?
import tensorflow as tf
rnn = tf.keras.layers.SimpleRNN(10)
inputs = tf.random.uniform((32, 10))
outputs = rnn(inputs)
TensorFlow
import tensorflow as tf rnn = tf.keras.layers.SimpleRNN(10) inputs = tf.random.uniform((32, 10)) outputs = rnn(inputs)
Attempts:
2 left
💡 Hint
Check the expected input shape for SimpleRNN layers.
✗ Incorrect
SimpleRNN expects input shape (batch_size, timesteps, features). The input here is 2D (batch_size, timesteps) missing features dimension, causing ValueError.