Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a SimpleRNN layer with 50 units.
TensorFlow
from tensorflow.keras.layers import SimpleRNN rnn_layer = SimpleRNN([1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number too small or too large without reason.
Forgetting to specify the number of units.
✗ Incorrect
The SimpleRNN layer requires the number of units as the first argument. Here, 50 units are specified.
2fill in blank
mediumComplete the code to add a SimpleRNN layer to a Sequential model.
TensorFlow
from tensorflow.keras.models import Sequential from tensorflow.keras.layers import SimpleRNN model = Sequential() model.add(SimpleRNN([1], input_shape=(10, 8)))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not specifying input_shape in the first layer.
Choosing a number of units that is too small or too large.
✗ Incorrect
The SimpleRNN layer is added with 32 units and an input shape of 10 time steps and 8 features.
3fill in blank
hardFix the error in the SimpleRNN layer creation by completing the code.
TensorFlow
from tensorflow.keras.layers import SimpleRNN rnn = SimpleRNN(units=[1], return_sequences=True)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing units as a string instead of an integer.
Using invalid types like None or True for units.
✗ Incorrect
The units argument must be an integer, not a string or other type. 20 is a valid integer.
4fill in blank
hardFill both blanks to create a SimpleRNN layer that returns sequences and uses tanh activation.
TensorFlow
rnn_layer = SimpleRNN([1], activation=[2], return_sequences=True)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'relu' instead of 'tanh' for activation.
Not setting return_sequences=True when needed.
✗ Incorrect
The layer has 40 units and uses 'tanh' activation, which is the default for SimpleRNN.
5fill in blank
hardFill all three blanks to build a Sequential model with a SimpleRNN layer followed by a Dense output layer.
TensorFlow
from tensorflow.keras.models import Sequential from tensorflow.keras.layers import SimpleRNN, Dense model = Sequential([ SimpleRNN([1], input_shape=(15, 10), activation=[2]), Dense([3], activation='softmax') ])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the order of layers.
Using wrong activation functions.
Incorrect output size in Dense layer.
✗ Incorrect
The SimpleRNN layer has 32 units with 'relu' activation, and the Dense layer outputs 5 classes with softmax.