第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

加載 word2vec 模型時(shí)出現(xiàn)數(shù)組重塑錯(cuò)誤

加載 word2vec 模型時(shí)出現(xiàn)數(shù)組重塑錯(cuò)誤

慕容森 2023-05-23 16:39:10
我有以下代碼:from gensim.models import Word2Vecmodel = Word2Vec.load('model2')X = model[model.wv.vocab]這段代碼適用于我的一臺(tái)機(jī)器,但不適用于另一臺(tái)機(jī)器。模型文件是一樣的。這是怎么回事?我收到的錯(cuò)誤消息如下:  File "/home/ec2-user/miniconda3/envs/word2vec/lib/python3.7/site-packages/gensim/models/word2vec.py", line 1330, in load    model = super(Word2Vec, cls).load(*args, **kwargs)  File "/home/ec2-user/miniconda3/envs/word2vec/lib/python3.7/site-packages/gensim/models/base_any2vec.py", line 1244, in load    model = super(BaseWordEmbeddingsModel, cls).load(*args, **kwargs)  File "/home/ec2-user/miniconda3/envs/word2vec/lib/python3.7/site-packages/gensim/models/base_any2vec.py", line 603, in load    return super(BaseAny2VecModel, cls).load(fname_or_handle, **kwargs)  File "/home/ec2-user/miniconda3/envs/word2vec/lib/python3.7/site-packages/gensim/utils.py", line 427, in load    obj._load_specials(fname, mmap, compress, subname)  File "/home/ec2-user/miniconda3/envs/word2vec/lib/python3.7/site-packages/gensim/utils.py", line 458, in _load_specials    getattr(self, attrib)._load_specials(cfname, mmap, compress, subname)  File "/home/ec2-user/miniconda3/envs/word2vec/lib/python3.7/site-packages/gensim/utils.py", line 469, in _load_specials    val = np.load(subname(fname, attrib), mmap_mode=mmap)  File "/home/ec2-user/miniconda3/envs/word2vec/lib/python3.7/site-packages/numpy/lib/npyio.py", line 440, in load    pickle_kwargs=pickle_kwargs)  File "/home/ec2-user/miniconda3/envs/word2vec/lib/python3.7/site-packages/numpy/lib/format.py", line 771, in read_array    array.shape = shapeValueError: cannot reshape array of size 16777184 into shape (134441,128)為了安裝 gensim,我使用了conda install -c anaconda gensim
查看完整描述

1 回答

?
冉冉說

TA貢獻(xiàn)1877條經(jīng)驗(yàn) 獲得超1個(gè)贊

文件大小是錯(cuò)誤的。上傳過程中一定發(fā)生了什么。對(duì)于大型模型,word2vec 將模型保存在 3 個(gè)文件中。假設(shè)您的模型名稱是“model2”,您將擁有:

  1. 模型2

  2. model2.trainables.syn1neg.npy

  3. 模型2.wv.vectors.npy

我的.wv.vectors.npy版本比我其他機(jī)器上的版本小了幾千字節(jié)。


查看完整回答
反對(duì) 回復(fù) 2023-05-23
  • 1 回答
  • 0 關(guān)注
  • 206 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)