diff --git a/serialization/src/TorchForceProxy.cpp b/serialization/src/TorchForceProxy.cpp index 840eada..ef548b7 100644 --- a/serialization/src/TorchForceProxy.cpp +++ b/serialization/src/TorchForceProxy.cpp @@ -111,7 +111,9 @@ void* TorchForceProxy::deserialize(const SerializationNode& node) const { } else { const string storedEncodedFile = node.getStringProperty("encodedFileContents"); string fileName = tmpnam(nullptr); // A unique filename - ofstream(fileName) << hexDecode(storedEncodedFile); + ofstream ofs = ofstream(fileName, ios::binary); + ofs << hexDecode(storedEncodedFile); + ofs.close(); auto model = torch::jit::load(fileName); std::remove(fileName.c_str()); force = new TorchForce(model);