I have been trying very long but unable to fix the below error
Error
File "C:\amnpawar\AIenv\lib\site-packages\gensim\models\deprecated\doc2vec.py", line 91, in load_old_doc2vec
old_model = Doc2Vec.load(*args, **kwargs)
File "C:\amnpawar\AIenv\lib\site-packages\gensim\models\deprecated\word2vec.py", line 1617, in load
model = super(Word2Vec, cls).load(*args, **kwargs)
File "C:\amnpawar\AIenv\lib\site-packages\gensim\models\deprecated\old_saveload.py", line 88, in load obj._load_specials(fname, mmap, compress, subname)
AttributeError: 'CountVectorizer' object has no attribute '_load_specials'
Indeed you've been struggling with this for a long time, but the answer is essentially the same as was given when you asked a version of it in September, and I answered: https://stackoverflow.com/a/73660204/130288
Don't try to use any Gensim
.load()method to load a non-Gensim saved object.CountVectorizerisn't a Gensim class. This error suggests the file you're trying to load here is a pickle-serialization of aCountVectorizerobject, not a GensimDoc2Vecobject.Looking at the code from your previous question, it's likely the initial error you made was using
pickle.dump()to write theCountVectorizerinto the same filename as the earlierDoc2Vecmodel.save(). So, that file no longer contains aDoc2Vecobject. Whatever was saved initially has been overwritten.If you want to load this file, use the same
pickle.load()as was in your initial question code, but the loaded object you get won't be aDoc2Vecmodel, it'll be aCountVectorizer.To load a
Doc2Vecmodel, you'll need to use a different file that actually contains aDoc2Vecmodel. (If you don't have any, because your original model file was overwritten when you saved theCountVectorizerto it, you'll need to train anotherDoc2Vecmodel.)