I trained a word2vec model using gensim on my local machine and uploaded all files to AWS. I am able to load the model on my local machine but loading on AWS gives
FileNotFoundError: [Errno 2] No such file or directory: 's3://saltsagemaker/models/bilstm_models/word2vec/word2vec_model.wv.vectors.npy'
This works 👇🏻
# LOCAL MACHINE
from gensim.models import Phrases, Word2Vec
WV_MODEL = 'model_train_script/models/bilstm_models/word2vec/word2vec_model'
wv_model = Word2Vec.load(WV_MODEL)
This doesnt works 👇🏻
# AWS CODE
from gensim.models import Phrases, Word2Vec
WV_MODEL = 's3://saltsagemaker/models/bilstm_models/word2vec/word2vec_model'
wv_model = Word2Vec.load(WV_MODEL)
above code gives the following
FileNotFoundError: [Errno 2] No such file or directory: 's3://saltsagemaker/models/bilstm_models/word2vec/word2vec_model.wv.vectors.npy'
The numpy
code on which Gensim relies to load subsidiary files (like your word2vec_model.wv.vectors.npy
) doesn't support remote S3 paths like 's3://saltsagemaker/models/bilstm_models/word2vec/word2vec_model.wv.vectors.npy'
. So, it's interpreting it as if it were a local path – & finding nothing.
You could:
.save()
& .load()
methods at all, & instead use Python's pickle
functionality to write the model object to a single file, then use unpickle
on that single file to read it back in from a single S3 path