0
0
NLPml~10 mins

Bidirectional LSTM 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 Bidirectional layer from Keras.

NLP
from tensorflow.keras.layers import [1]
Drag options to blanks, or click blank then click option'
ABidirectional
BDense
CConv2D
DDropout
Attempts:
3 left
💡 Hint
Common Mistakes
Importing Dense or Conv2D instead of Bidirectional.
Forgetting to import Bidirectional layer.
2fill in blank
medium

Complete the code to create a Bidirectional LSTM layer with 64 units.

NLP
model.add(Bidirectional([1](64)))
Drag options to blanks, or click blank then click option'
ADense
BLSTM
CGRU
DConv1D
Attempts:
3 left
💡 Hint
Common Mistakes
Using Dense or Conv1D inside Bidirectional, which is incorrect.
Using GRU instead of LSTM if the question specifically asks for LSTM.
3fill in blank
hard

Fix the error in the code to correctly compile the model with categorical crossentropy loss.

NLP
model.compile(optimizer='adam', loss='[1]', metrics=['accuracy'])
Drag options to blanks, or click blank then click option'
Acategorical_crossentropy
Bmean_squared_error
Cbinary_crossentropy
Dhinge
Attempts:
3 left
💡 Hint
Common Mistakes
Using mean_squared_error for classification.
Using binary_crossentropy for multi-class problems.
4fill in blank
hard

Fill both blanks to create a Bidirectional LSTM layer that returns sequences and uses 128 units.

NLP
model.add(Bidirectional([1](128, [2]=True)))
Drag options to blanks, or click blank then click option'
ALSTM
Breturn_sequences
Cactivation
Dunits
Attempts:
3 left
💡 Hint
Common Mistakes
Using activation or units as keyword argument instead of return_sequences.
Not setting return_sequences when needed.
5fill in blank
hard

Fill all three blanks to build a simple Bidirectional LSTM model for text classification.

NLP
model = Sequential()
model.add(Embedding(input_dim=[1], output_dim=[2], input_length=100))
model.add(Bidirectional(LSTM([3])))
model.add(Dense(5, activation='softmax'))
Drag options to blanks, or click blank then click option'
A10000
B64
C128
D32
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing input_dim and output_dim values.
Using too small or too large numbers for embedding or LSTM units.