Takes .prototxt and .caffemodel filenames from ARGV and fills the model with trained weights. The resulting binary model with weights to be consumed by nnc is printed to StdOut.
More...
#include <MergeCommand.h>
|
int | run (int argc, const char *const *argv) const override |
|
Public Member Functions inherited from cli::Command |
virtual | ~Command ()=default |
|
Takes .prototxt and .caffemodel filenames from ARGV and fills the model with trained weights. The resulting binary model with weights to be consumed by nnc is printed to StdOut.
- Returns
- error code
Definition at line 28 of file MergeCommand.h.
◆ run()
int MergeCommand::run |
( |
int |
argc, |
|
|
const char *const * |
argv |
|
) |
| const |
|
overridevirtual |
Implements cli::Command.
Definition at line 29 of file MergeCommand.cpp.
30{
31 if (argc != 2)
32 {
33 std::cerr << "ERROR: this command requires exactly 2 arguments" << std::endl;
34 return 254;
35 }
36
37 std::string model_file =
argv[0];
38 std::string trained_file =
argv[1];
39
40
41 caffe::Net<float> caffe_test_net(model_file, caffe::TEST);
42
43 caffe_test_net.CopyTrainedLayersFrom(trained_file);
44
45 caffe::NetParameter net_param;
46 caffe_test_net.ToProto(&net_param);
47
48
49 google::protobuf::io::OstreamOutputStream os(&std::cout);
50 google::protobuf::io::CodedOutputStream coded_os{&os};
51
52 if (!net_param.SerializeToCodedStream(&coded_os))
53 {
54 std::cerr << "ERROR: Failed to serialize" << std::endl;
55 return 255;
56 }
57 return 0;
58}
The documentation for this struct was generated from the following files: