diff --git a/src/caffe/util/io.cpp b/src/caffe/util/io.cpp index 122d1a77a77..44858f48a36 100644 --- a/src/caffe/util/io.cpp +++ b/src/caffe/util/io.cpp @@ -44,7 +44,7 @@ bool ReadProtoFromTextFile(const char* filename, Message* proto) { } void WriteProtoToTextFile(const Message& proto, const char* filename) { - int fd = open(filename, O_WRONLY); + int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644); FileOutputStream* output = new FileOutputStream(fd); CHECK(google::protobuf::TextFormat::Print(proto, output)); delete output; diff --git a/tools/upgrade_net_proto_text.cpp b/tools/upgrade_net_proto_text.cpp index aefdc7e2961..8a77f752cc2 100644 --- a/tools/upgrade_net_proto_text.cpp +++ b/tools/upgrade_net_proto_text.cpp @@ -44,13 +44,8 @@ int main(int argc, char** argv) { NetParameterPrettyPrint net_param_pretty; NetParameterToPrettyPrint(net_param, &net_param_pretty); - // TODO(jdonahue): figure out why WriteProtoToTextFile doesn't work - // (no file is created). - // WriteProtoToTextFile(net_param_pretty, argv[2]); - ofstream output_proto; - output_proto.open(argv[2]); - output_proto << net_param_pretty.DebugString(); - output_proto.close(); + // Save new format prototxt. + WriteProtoToTextFile(net_param_pretty, argv[2]); LOG(ERROR) << "Wrote upgraded NetParameter text proto to " << argv[2]; return !success;