Bird
0
0

Identify the error in this Word2Vec training code snippet: from gensim.models import Word2Vec sentences = [['data', 'science'], ['deep', 'learning']] model = Word2Vec(sentences, vector_size=100, window=5, sg=2) model.train(sentences, total_examples=2, epochs=10)

medium📝 Debug Q6 of 15
NLP - Word Embeddings
Identify the error in this Word2Vec training code snippet: from gensim.models import Word2Vec sentences = [['data', 'science'], ['deep', 'learning']] model = Word2Vec(sentences, vector_size=100, window=5, sg=2) model.train(sentences, total_examples=2, epochs=10)
Asg parameter value 2 is invalid; should be 0 or 1
Bvector_size must be less than window size
Ctrain method missing required callbacks argument
Dtotal_examples should be number of words, not sentences
Step-by-Step Solution
Solution:
  1. Step 1: Check valid values for sg parameter

    sg can only be 0 (CBOW) or 1 (Skip-gram). 2 is invalid.
  2. Step 2: Verify other parameters

    vector_size and window sizes are valid; train method usage is correct.
  3. Final Answer:

    sg parameter value 2 is invalid; should be 0 or 1 -> Option A
  4. Quick Check:

    sg must be 0 or 1 [OK]
Quick Trick: sg parameter only accepts 0 or 1 [OK]
Common Mistakes:
MISTAKES
  • Using invalid sg values
  • Confusing vector_size and window constraints
  • Misunderstanding train method parameters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NLP Quizzes