Challenge - 5 Problems
Pre-trained Embedding Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of embedding vector shape
What is the shape of the output embedding vector when using a pre-trained embedding layer with input size 10 and embedding dimension 50 for a batch of 3 samples?
NLP
import torch import torch.nn as nn embedding = nn.Embedding(num_embeddings=10, embedding_dim=50) input_indices = torch.tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) output = embedding(input_indices) print(output.shape)
Attempts:
2 left
💡 Hint
Think about the input shape and how embedding layers map indices to vectors.
✗ Incorrect
The input tensor has shape (3, 3) representing 3 samples each with 3 indices. The embedding layer converts each index to a 50-dimensional vector, so the output shape is (3, 3, 50).
❓ Model Choice
intermediate2:00remaining
Choosing pre-trained embeddings for sentiment analysis
You want to build a sentiment analysis model on movie reviews. Which pre-trained embedding is best suited to capture semantic meaning of words in this context?
Attempts:
2 left
💡 Hint
Consider embeddings trained on large text corpora relevant to general language.
✗ Incorrect
GloVe embeddings trained on Common Crawl capture semantic relationships between words from a large text corpus, making them suitable for sentiment analysis tasks.
❓ Hyperparameter
advanced2:00remaining
Effect of freezing pre-trained embeddings
What is the effect of freezing the weights of a pre-trained embedding layer during training?
Attempts:
2 left
💡 Hint
Freezing means preventing changes to the weights.
✗ Incorrect
Freezing the embedding layer means its weights stay fixed and do not update during training, preserving the original pre-trained knowledge.
❓ Metrics
advanced2:00remaining
Evaluating embedding quality with downstream task accuracy
You compare two pre-trained embeddings by training the same classifier on a text classification task. Embedding A yields 85% accuracy, embedding B yields 78%. What can you conclude?
Attempts:
2 left
💡 Hint
Higher accuracy usually means better feature representation for the task.
✗ Incorrect
Higher accuracy indicates that embedding A provides better features for the classifier on this task compared to embedding B.
🔧 Debug
expert3:00remaining
Identifying error when loading pre-trained embeddings
You try to load pre-trained embeddings into your model but get a size mismatch error. What is the most likely cause?
NLP
import torch import torch.nn as nn embedding = nn.Embedding(num_embeddings=1000, embedding_dim=300) pretrained_weights = torch.randn(500, 300) embedding.weight.data.copy_(pretrained_weights)
Attempts:
2 left
💡 Hint
Check the shape of pretrained weights vs model embedding weights.
✗ Incorrect
The pretrained weights have 500 embeddings but the model expects 1000, so copying causes a size mismatch error.