Selaa lähdekoodia

Open model file in binary mode in saveModel and loadModel

Summary: Open model file in binary model in saveModel and loadModel.

Reviewed By: ajoulin

Differential Revision: D3852452

fbshipit-source-id: e591a462b6d272e9bcbfb74cd414d037e1acb6b9
Edouard Grave 9 vuotta sitten
vanhempi
sitoutus
7b21700ce8
1 muutettua tiedostoa jossa 2 lisäystä ja 2 poistoa
  1. 2 2
      src/fasttext.cc

+ 2 - 2
src/fasttext.cc

@@ -47,7 +47,7 @@ void FastText::saveVectors() {
 }
 
 void FastText::saveModel() {
-  std::ofstream ofs(args_->output + ".bin");
+  std::ofstream ofs(args_->output + ".bin", std::ofstream::binary);
   if (!ofs.is_open()) {
     std::cerr << "Model file cannot be opened for saving!" << std::endl;
     exit(EXIT_FAILURE);
@@ -60,7 +60,7 @@ void FastText::saveModel() {
 }
 
 void FastText::loadModel(const std::string& filename) {
-  std::ifstream ifs(filename);
+  std::ifstream ifs(filename, std::ifstream::binary);
   if (!ifs.is_open()) {
     std::cerr << "Model file cannot be opened for loading!" << std::endl;
     exit(EXIT_FAILURE);