Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a simple RNN layer in TensorFlow.
TensorFlow
rnn_layer = tf.keras.layers.SimpleRNN([1], input_shape=(10, 8))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a layer type instead of a number for units.
Passing activation function as the first argument.
✗ Incorrect
The number 32 specifies the number of units (neurons) in the RNN layer, which is required to create the layer.
2fill in blank
mediumComplete the code to compile the RNN model with an optimizer.
TensorFlow
model.compile(optimizer='[1]', loss='mse')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using activation functions instead of optimizer names.
Using metrics like 'accuracy' as optimizer.
✗ Incorrect
The optimizer 'adam' is commonly used for training RNNs and other neural networks.
3fill in blank
hardFix the error in the code to correctly reshape input data for the RNN.
TensorFlow
input_data = input_data.reshape(([1], 10, 8))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using sequence length or feature size as the first dimension.
Using fixed numbers instead of batch size variable.
✗ Incorrect
The first dimension should be the batch size to match the model input requirements.
4fill in blank
hardFill both blanks to create a dictionary comprehension that maps each word to its length if the length is greater than 3.
TensorFlow
{word: [1] for word in words if [2] > 3} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using word.length which is not valid in Python.
Using the word itself instead of its length.
✗ Incorrect
We use len(word) to get the length of the word and check if it is greater than 3.
5fill in blank
hardFill all three blanks to create a dictionary that maps uppercase words to their lengths if length is greater than 4.
TensorFlow
{ [1]: [2] for word in words if [3] > 4 } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using word.lower() instead of upper().
Using the word itself as the value instead of its length.
✗ Incorrect
We convert the word to uppercase for the key, use len(word) for the value, and check if length is greater than 4.