Net constructor
| 90 | |
| 91 | // Net constructor |
| 92 | shared_ptr<Net<Dtype> > Net_Init(string network_file, int phase, |
| 93 | const int level, const bp::object& stages, |
| 94 | const bp::object& weights) { |
| 95 | CheckFile(network_file); |
| 96 | |
| 97 | // Convert stages from list to vector |
| 98 | vector<string> stages_vector; |
| 99 | if (!stages.is_none()) { |
| 100 | for (int i = 0; i < len(stages); i++) { |
| 101 | stages_vector.push_back(bp::extract<string>(stages[i])); |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | // Initialize net |
| 106 | shared_ptr<Net<Dtype> > net(new Net<Dtype>(network_file, |
| 107 | static_cast<Phase>(phase), level, &stages_vector)); |
| 108 | |
| 109 | // Load weights |
| 110 | if (!weights.is_none()) { |
| 111 | std::string weights_file_str = bp::extract<std::string>(weights); |
| 112 | CheckFile(weights_file_str); |
| 113 | net->CopyTrainedLayersFrom(weights_file_str); |
| 114 | } |
| 115 | |
| 116 | return net; |
| 117 | } |
| 118 | |
| 119 | // Legacy Net construct-and-load convenience constructor |
| 120 | shared_ptr<Net<Dtype> > Net_Init_Load( |
nothing calls this directly
no test coverage detected