Bird
0
0

Consider the following Python code using Gensim's FastText:

medium📝 Predict Output Q4 of 15
NLP - Word Embeddings
Consider the following Python code using Gensim's FastText:
from gensim.models import FastText
sentences = [['data', 'science'], ['machine', 'learning']]
model = FastText(sentences, vector_size=8, window=2, min_count=1, epochs=4)
print(model.wv['machine'].shape)
What will be the output?
A(1, 8)
B(4, 8)
C(8,)
DError: KeyError
Step-by-Step Solution
Solution:
  1. Step 1: Identify vector size

    The model is initialized with vector_size=8, so each word vector has 8 dimensions.
  2. Step 2: Check word presence

    'machine' is in the training sentences, so no KeyError occurs.
  3. Step 3: Understand output shape

    model.wv['machine'] returns a 1D numpy array of length 8, so shape is (8,)
  4. Final Answer:

    (8,) -> Option C
  5. Quick Check:

    Vector size matches output shape [OK]
Quick Trick: Output shape equals vector_size tuple [OK]
Common Mistakes:
MISTAKES
  • Expecting a 2D array shape
  • Assuming KeyError for known words
  • Confusing epochs with vector dimensions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NLP Quizzes