Skip to content

Commit

Permalink
Save output vectors for supervised model
Browse files Browse the repository at this point in the history
Summary: Save output vectors for supervised models, by using the command line option `-saveOutput 1`

Reviewed By: cpuhrsch

Differential Revision: D4716136

fbshipit-source-id: fd023434587de953ea8af6b7e5caaf8c5149ca78
  • Loading branch information
Edouard Grave authored and facebook-github-bot committed Sep 26, 2017
1 parent 7e5c955 commit 437f878
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/fasttext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,13 @@ void FastText::saveOutput() {
<< std::endl;
return;
}
ofs << dict_->nwords() << " " << args_->dim << std::endl;
int32_t n = (args_->model == model_name::sup) ? dict_->nlabels()
: dict_->nwords();
ofs << n << " " << args_->dim << std::endl;
Vector vec(args_->dim);
for (int32_t i = 0; i < dict_->nwords(); i++) {
std::string word = dict_->getWord(i);
for (int32_t i = 0; i < n; i++) {
std::string word = (args_->model == model_name::sup) ? dict_->getLabel(i)
: dict_->getWord(i);
vec.zero();
vec.addRow(*output_, i);
ofs << word << " " << vec << std::endl;
Expand Down

0 comments on commit 437f878

Please sign in to comment.