0
0
NLPml~10 mins

Embedding layer usage 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 create an embedding layer with input dimension 1000 and output dimension 64.

NLP
embedding = nn.Embedding([1], 64)
Drag options to blanks, or click blank then click option'
A10
B64
C128
D1000
Attempts:
3 left
💡 Hint
Common Mistakes
Using the output dimension as the input dimension
Confusing input and output dimensions
2fill in blank
medium

Complete the code to convert input word indices to embeddings using the embedding layer.

NLP
embedded_words = embedding([1])
Drag options to blanks, or click blank then click option'
Aword_indices
Bembedding
Cinput_dim
Doutput_dim
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the embedding layer itself as input
Passing dimensions instead of indices
3fill in blank
hard

Fix the error in the embedding layer initialization by filling the correct padding index.

NLP
embedding = nn.Embedding(1000, 64, padding_idx=[1])
Drag options to blanks, or click blank then click option'
A-1
B0
C64
D1000
Attempts:
3 left
💡 Hint
Common Mistakes
Using -1 which is invalid
Using output dimension as padding index
4fill in blank
hard

Fill both blanks to create an embedding layer and get embeddings for input indices.

NLP
embedding = nn.Embedding([1], [2])
embedded = embedding(input_indices)
Drag options to blanks, or click blank then click option'
A5000
B128
C64
D1000
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping input and output dimensions
Using wrong vocabulary size
5fill in blank
hard

Fill all three blanks to create an embedding layer, set padding index, and get embeddings.

NLP
embedding = nn.Embedding([1], [2], padding_idx=[3])
embedded = embedding(batch_indices)
Drag options to blanks, or click blank then click option'
A10000
B300
C0
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid padding index
Confusing embedding size with vocabulary size