Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

382
Views
Gensim word2vec en python3 vocabulario faltante

Estoy usando la implementación gensim de Word2Vec. Tengo el siguiente fragmento de código:

 print('training model') model = Word2Vec(Sentences(start, end)) print('trained model:', model) print('vocab:', model.vocab.keys())

Cuando ejecuto esto en python2, funciona como se esperaba. La impresión final son todas las palabras del vocabulario.

Sin embargo, si lo ejecuto en python3, aparece un error:

 trained model: Word2Vec(vocab=102, size=100, alpha=0.025) Traceback (most recent call last): File "learn.py", line 58, in <module> train(to_datetime('-4h'), to_datetime('now'), 'model.out') File "learn.py", line 23, in train print('vocab:', model.vocab.keys()) AttributeError: 'Word2Vec' object has no attribute 'vocab'

¿Qué está pasando? ¿Gensim word2vec no es compatible con python3?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

¿Está utilizando la misma versión de gensim en ambos lugares? Gensim 1.0.0 mueve vocab a un objeto auxiliar, por lo que en las versiones anteriores a 1.0.0 de gensim (en Python 2 o 3), puede usar:

 model.vocab

...en gensim 1.0.0+ deberías usar (en Python 2 o 3)...

 model.wv.vocab
over 4 years ago · Santiago Trujillo Report

0

Si está utilizando gensim 3.00+, podemos usar:

 model.wv.key_to_index

Para más información:

https://github.com/RaRe-Technologies/gensim/wiki/Migrating-from-Gensim-3.x-to-4

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!