Bird
0
0

Which of the following is the correct way to define a GRU layer in Python using PyTorch for text input with embedding size 100 and hidden size 50?

easy📝 Syntax Q12 of 15
NLP - Sequence Models for NLP
Which of the following is the correct way to define a GRU layer in Python using PyTorch for text input with embedding size 100 and hidden size 50?
Ann.GRU(hidden_size=100, input_size=50)
Bnn.GRU(50, 100)
Cnn.GRU(input_size=100, hidden_size=50)
Dnn.GRU(100)
Step-by-Step Solution
Solution:
  1. Step 1: Recall PyTorch GRU parameters

    PyTorch GRU expects input_size first (embedding size), then hidden_size (number of features in hidden state).
  2. Step 2: Match parameters to given sizes

    Embedding size is 100, hidden size is 50, so nn.GRU(input_size=100, hidden_size=50) is correct.
  3. Final Answer:

    nn.GRU(input_size=100, hidden_size=50) -> Option C
  4. Quick Check:

    input_size=100, hidden_size=50 = B [OK]
Quick Trick: Input size first, hidden size second in nn.GRU() [OK]
Common Mistakes:
MISTAKES
  • Swapping input_size and hidden_size
  • Using positional args incorrectly
  • Omitting required parameters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NLP Quizzes