template <typename Dtype>
void Net<Dtype>::CopyTrainedLayersFrom(const NetParameter& param) {
int num_source_layers = param.layer_size();
for (int i = 0; i < num_source_layers; ++i) {
const LayerParameter& source_layer = param.layer(i);
const string& source_layer_name = source_layer.name();
int target_layer_id = 0;
while (target_layer_id != layer_names_.size() &&
layer_names_[target_layer_id] != source_layer_name) {
++target_layer_id;
}
If the network has two layers with the same name, the weights of the two layers will be copied from the caffemodel to the first layer in turn. As a result, the weight of the first layer takes the weight of the second layer, and the second layer has no weight.
If the network has two layers with the same name, the weights of the two layers will be copied from the caffemodel to the first layer in turn. As a result, the weight of the first layer takes the weight of the second layer, and the second layer has no weight.