Practice
1. Given the following Python code using Word2Vec, what is the output shape of the word vector for 'king'?
from gensim.models import Word2Vec
model = Word2Vec(sentences, vector_size=100, window=5, min_count=1, workers=4)
vector = model.wv['king']easy
Solution
Step 1: Understand Word2Vec output
The Word2Vec model returns a 1D array of the specified vector size for each word.Step 2: Determine the shape
The vector size is set to 100, so the output shape is (100,).Final Answer:
Option C -> Option CQuick Check:
Word2Vec outputs 1D vector of size [OK]
Hint: Word2Vec outputs 1D vector of size [OK]
Common Mistakes:
2. Given the following PyTorch code snippet for a simple GNN layer, what will be the output shape if the input node features have shape (5, 10) and the adjacency matrix is (5, 5)?
import torch.nn as nn
import torch
class SimpleGNNLayer(nn.Module):
def __init__(self, in_features, out_features):
super(SimpleGNNLayer, self).__init__()
self.linear = nn.Linear(in_features, out_features)
def forward(self, x, adj):
return torch.matmul(adj, self.linear(x))
x = torch.randn(5, 10)
adj = torch.eye(5)
gnn_layer = SimpleGNNLayer(10, 20)
output = gnn_layer(x, adj)easy
Solution
Step 1: Understand the operations
The linear layer transforms the input features from 10 to 20 dimensions.Step 2: Apply the adjacency matrix
The adjacency matrix is used to aggregate features, maintaining the node count.Final Answer:
Option A -> Option AQuick Check:
Linear layer changes feature dim, adj keeps node count. [check]
Hint: Linear layer changes feature dim, adj keeps node count. [check]
Common Mistakes:
3. A model is showing unexpectedly high validation accuracy but low test accuracy. What is the most likely cause?
medium
Solution
Step 1: Diagnose the issue
High validation accuracy but low test accuracy suggests the validation set may not be representative.Step 2: Eliminate wrong options
The model is underfitting the training data. would affect both validation and test accuracy, The test set is too similar to the training set. would not cause low test accuracy, and The model has too many parameters. would affect both validation and test accuracy similarly.Final Answer:
Option D -> Option DQuick Check:
Small validation set = misleading accuracy [OK]
Hint: Small validation set = misleading accuracy [OK]
Common Mistakes:
4. For a regression task with a large number of outliers, which metric would be more appropriate to use?
medium
Solution
Step 1: Consider the impact of outliers on metrics.
Huber Loss is less sensitive to outliers than MSE and RMSE.Step 2: Eliminate wrong options.
MSE and RMSE amplify outliers due to squaring. MAPE is not suitable for zero or near-zero values.Final Answer:
Option B -> Option BQuick Check:
Huber Loss balances sensitivity to outliers. [OK]
Hint: Huber Loss balances sensitivity to outliers. [OK]
Common Mistakes:
5. You are tasked with designing a GNN for a dynamic graph where nodes and edges change over time. Which approach would best handle this scenario?
hard
Solution
Step 1: Understand the graph dynamics
Dynamic graphs require models that can adapt to changes in nodes and edges.Step 2: Evaluate each approach
Static GCNs and fixed adjacency matrices cannot adapt to changes, and RNNs are not designed for graph structures.Final Answer:
Option A -> Option AQuick Check:
Dynamic GNNs adapt to graph changes. [check]
Hint: Dynamic GNNs adapt to graph changes. [check]
Common Mistakes:
