AttributeError: 'spacy.vectors.Vectors' object has no attribute 'borrow'
henokDES opened this issue · 4 comments
How to reproduce the behaviour
Your Environment
- Operating System:
- windows 11
- Python Version Used:
- 3.8.5
- spaCy Version Used:
- '3.0.3'
- sense2vec version:
- '2.0.0'
- Environment Information:
AttributeError Traceback (most recent call last)
in
25 continue
26 vector = w2v_model.wv.vectors[idx]
---> 27 vector_map.borrow(string, vector)
28
29 print("saving the model to file...")AttributeError: 'spacy.vectors.Vectors' object has no attribute 'borrow'
Hi, could you provide a bit more context about the code that you're running, the full error message, and the output of spacy info
?
w2v_model = Word2Vec(
size = 128,
iter=2,
window= 5 ,
min_count=1,
workers=number_cores,
sample=1e-5,
)sentences = tokens
print("building the vocabulary...")
w2v_model.build_vocab(sentences)print("training the model...")
w2v_model.train(sentences, total_examples=w2v_model.corpus_count, epochs=w2v_model.iter)print("creating the sense2vec model...")
vector_map = Vectors(shape=(18447, 128))
min_count = 1
for string in w2v_model.wv.vocab:
vocab = w2v_model.wv.vocab[string]
freq, idx = vocab.count, vocab.index
if freq < min_count:
continue
vector = w2v_model.wv.vectors[idx]
vector_map.borrow(string, freq, vector)print("saving the model to file...")
#vector_map.save(out_path)
here is the whole code sense2vec version '2.0.0' and spacy version '3.0.3'
AttributeError Traceback (most recent call last)
in
25 continue
26 vector = w2v_model.wv.vectors[idx]
---> 27 vector_map.borrow(string, vector)
28
29 print("saving the model to file...")AttributeError: 'spacy.vectors.Vectors' object has no attribute 'borrow'
Hmm, somehow you've ended up with some old/prerelease sense2vec code that was written for a much older version of spacy.
Try to uninstall and reinstall sense2vec or start again in a clean venv, double-checking that you have a compatible version of spacy after the install. For sense2vec v2.0.0 this is spacy v3.x; for sense2vec v1.0.3 this is spacy v2.2 or v2.3.
If you install sense2vec in a new venv with pip, it should automatically install a compatible version of spacy.
Let me move this to the discussion board. This issue will be locked but you can follow the link to the new thread.