BVLC / caffe

Caffe: a fast open framework for deep learning.
http://caffe.berkeleyvision.org/
Other
33.96k stars 18.72k forks source link

[bug] duplicate layer name with same shape weight #7043

Open lzwhard opened 2 years ago

lzwhard commented 2 years ago
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.

TrevorBlythe commented 2 years ago

Name them differently?