Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the RNN layer from TensorFlow Keras.
NLP
from tensorflow.keras.layers import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing Dense instead of SimpleRNN
Confusing convolutional layers with RNN layers
✗ Incorrect
The SimpleRNN layer is used for building recurrent neural networks for sequence data.
2fill in blank
mediumComplete the code to define an RNN model with an embedding layer and a SimpleRNN layer.
NLP
model = Sequential([
Embedding(input_dim=1000, output_dim=64),
[1](128),
Dense(1000, activation='softmax')
]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Conv1D instead of a recurrent layer
Using Dropout where a recurrent layer is needed
✗ Incorrect
SimpleRNN is the recurrent layer used here to process the embedded sequences.
3fill in blank
hardFix the error in the code to compile the RNN model for text generation.
NLP
model.compile(optimizer='adam', loss=[1], metrics=['accuracy'])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using binary_crossentropy for multi-class output
Using mse which is for regression tasks
✗ Incorrect
For multi-class text generation, categorical_crossentropy is the correct loss function.
4fill in blank
hardFill both blanks to create a dictionary comprehension that maps words to their lengths only if length is greater than 3.
NLP
word_lengths = {word: [1] for word in words if len(word) [2] 3} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself as the value instead of its length
Using less than instead of greater than in the condition
✗ Incorrect
We want the length of each word as the value and only include words longer than 3 characters.
5fill in blank
hardFill all three blanks to create a dictionary comprehension that maps uppercase words to their counts only if count is greater than 0.
NLP
result = { [1]: [2] for word, count in word_counts.items() if count [3] 0 } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using word.lower() instead of word.upper()
Using less than instead of greater than in the condition
✗ Incorrect
We convert words to uppercase as keys, keep counts as values, and filter counts greater than zero.