Explorar o código

Save output vectors for supervised model

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
Edouard Grave %!s(int64=8) %!d(string=hai) anos
pai
achega
437f878bcc
Modificáronse 1 ficheiros con 6 adicións e 3 borrados
  1. 6 3
      src/fasttext.cc

+ 6 - 3
src/fasttext.cc

@@ -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;