0
0
TensorFlowml~20 mins

SimpleRNN layer in TensorFlow - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
SimpleRNN Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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)
A(32, 10, 16)
B(32, 16)
C(10, 16)
D(32, 8)
Attempts:
2 left
💡 Hint
SimpleRNN by default returns only the last output for each sequence.
Model Choice
intermediate
1:30remaining
Choosing SimpleRNN for sequence data
Which of the following tasks is best suited for a SimpleRNN layer?
APredicting the next word in a sentence based on previous words
BClassifying images of cats and dogs
CClustering customer data based on purchase history
DReducing dimensionality of tabular data
Attempts:
2 left
💡 Hint
SimpleRNN is designed to process sequences over time.
Hyperparameter
advanced
1:30remaining
Effect of return_sequences=True in SimpleRNN
What is the effect of setting return_sequences=True in a SimpleRNN layer?
AThe layer returns the output at each timestep, producing a 3D tensor
BThe layer returns the sum of all outputs across timesteps
CThe layer returns the input sequence unchanged
DThe layer returns only the last output, producing a 2D tensor
Attempts:
2 left
💡 Hint
Think about whether the output includes all timesteps or just the last one.
Metrics
advanced
1: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?
AThe model is underfitting both training and validation data
BThe model has a bug causing loss to increase
CThe model is perfectly generalizing to new data
DThe model is overfitting the training data
Attempts:
2 left
💡 Hint
Think about what it means when training loss improves but validation loss worsens.
🔧 Debug
expert
2: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)
ANo error, outputs shape will be (32, 10)
BTypeError because inputs are not integers
CValueError because input must be 3D but got 2D tensor
DRuntimeError due to missing activation function
Attempts:
2 left
💡 Hint
Check the expected input shape for SimpleRNN layers.