Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit431c9e2

Browse files
Edouard Gravefacebook-github-bot
Edouard Grave
authored andcommitted
Print error message for invalid pretrained model files
Summary: Print an error message for invalid pretrained models (i.e. non quantized models which have a pruneidx_idx_ field different than -1).Reviewed By: cpuhrschDifferential Revision: D6097450fbshipit-source-id: 203d1eeab03a3f8acb59926daa5ae2f54b7f236b
1 parentebbd3bf commit431c9e2

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

‎src/dictionary.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class Dictionary {
104104
std::minstd_rand&)const;
105105
voidthreshold(int64_t,int64_t);
106106
voidprune(std::vector<int32_t>&);
107+
boolisPruned() {return pruneidx_size_ >=0; }
107108
};
108109

109110
}

‎src/fasttext.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ void FastText::loadModel(std::istream& in) {
171171
input_->load(in);
172172
}
173173

174+
if (!quant_input && dict_->isPruned()) {
175+
std::cerr <<"Invalid model file.\n"
176+
<<"Please download the updated model from www.fasttext.cc.\n"
177+
<<"See issue #332 on Github for more information.\n";
178+
exit(1);
179+
}
180+
174181
in.read((char*) &args_->qout,sizeof(bool));
175182
if (quant_ && args_->qout) {
176183
qoutput_->load(in);
@@ -221,7 +228,8 @@ std::vector<int32_t> FastText::selectEmbeddings(int32_t cutoff) const {
221228

222229
voidFastText::quantize(std::shared_ptr<Args> qargs) {
223230
if (qargs->output.empty()) {
224-
std::cerr<<"No model provided!"<<std::endl;exit(1);
231+
std::cerr<<"No model provided!"<<std::endl;
232+
exit(1);
225233
}
226234
loadModel(qargs->output +".bin");
227235

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp