0
0
NLPml~10 mins

GRU for text in NLP - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the GRU layer from TensorFlow Keras.

NLP
from tensorflow.keras.layers import [1]
Drag options to blanks, or click blank then click option'
ALSTM
BGRU
CConv2D
DDense
Attempts:
3 left
💡 Hint
Common Mistakes
Importing LSTM instead of GRU
Importing Dense or Conv2D by mistake
2fill in blank
medium

Complete the code to create a GRU layer with 64 units and return sequences.

NLP
gru_layer = GRU([1], return_sequences=True)
Drag options to blanks, or click blank then click option'
A256
B32
C128
D64
Attempts:
3 left
💡 Hint
Common Mistakes
Using too few units like 32 which may underfit
Using too many units like 256 which may overfit or slow training
3fill in blank
hard

Fix the error in the code to compile the model with Adam optimizer and categorical crossentropy loss.

NLP
model.compile(optimizer='[1]', loss='categorical_crossentropy', metrics=['accuracy'])
Drag options to blanks, or click blank then click option'
Aadam
Badagrad
Crmsprop
Dsgd
Attempts:
3 left
💡 Hint
Common Mistakes
Using SGD which may require more tuning
Using RMSprop or Adagrad without understanding their effects
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps words to their lengths only if length is greater than 3.

NLP
{word: [1] for word in words if len(word) [2] 3}
Drag options to blanks, or click blank then click option'
Alen(word)
B>
C<
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself as value instead of its length
Using less than operator instead of greater than
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase words to their counts 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'
Aword.upper()
Bcount
C>
Dword.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using word.lower() instead of word.upper()
Using less than operator instead of greater than