Net constructor
| 107 | |
| 108 | // Net constructor |
| 109 | shared_ptr<Net<Dtype> > Net_Init(string network_file, int phase, |
| 110 | const int level, const bp::object& stages, |
| 111 | const bp::object& weights) { |
| 112 | CheckFile(network_file); |
| 113 | |
| 114 | // Convert stages from list to vector |
| 115 | vector<string> stages_vector; |
| 116 | if (!stages.is_none()) { |
| 117 | for (int i = 0; i < len(stages); i++) { |
| 118 | stages_vector.push_back(bp::extract<string>(stages[i])); |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | // Initialize net |
| 123 | shared_ptr<Net<Dtype> > net(new Net<Dtype>(network_file, |
| 124 | static_cast<Phase>(phase), level, &stages_vector)); |
| 125 | |
| 126 | // Load weights |
| 127 | if (!weights.is_none()) { |
| 128 | std::string weights_file_str = bp::extract<std::string>(weights); |
| 129 | CheckFile(weights_file_str); |
| 130 | net->CopyTrainedLayersFrom(weights_file_str); |
| 131 | } |
| 132 | |
| 133 | return net; |
| 134 | } |
| 135 | |
| 136 | // Legacy Net construct-and-load convenience constructor |
| 137 | shared_ptr<Net<Dtype> > Net_Init_Load( |
nothing calls this directly
no test coverage detected