MCPcopy Create free account
hub / github.com/BVLC/caffe / Net_Init

Function Net_Init

python/caffe/_caffe.cpp:109–134  ·  view source on GitHub ↗

Net constructor

Source from the content-addressed store, hash-verified

107
108// Net constructor
109shared_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
137shared_ptr<Net<Dtype> > Net_Init_Load(

Callers

nothing calls this directly

Calls 2

CheckFileFunction · 0.85
CopyTrainedLayersFromMethod · 0.80

Tested by

no test coverage detected