caffe icon indicating copy to clipboard operation
caffe copied to clipboard

[bug] duplicate layer name with same shape weight

Open lzwhard opened this issue 4 years ago • 1 comments

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.

lzwhard avatar Nov 17 '21 06:11 lzwhard

Name them differently?

TrevorBlythe avatar Apr 11 '22 01:04 TrevorBlythe