Closed venkai closed 6 years ago
Hi @venkai thanks for the tip. Could you please attach a sample model prototxt having this issue?
Hi @drnikolaev , here is a minimal prototxt that should reproduce the bug:
layer {
name: "L_input" type: "Input" top: "data"
input_param { shape { dim: 1 dim: 3 dim: 4 dim: 5 } }
}
layer {
name: "L0" type: "Convolution" bottom: "data" top: "B0"
convolution_param {
num_output: 8 pad: 1 kernel_size: 3
weight_filler { type: "gaussian" std: 0.001 }
bias_filler { type: "gaussian" mean: 0.1 std: 1 }
}
}
layer {
name: "L1" type: "Convolution" bottom: "B0" top: "B1"
convolution_param {
num_output: 8 pad: 1 kernel_size: 3
weight_filler { type: "gaussian" std: 0.001 }
bias_filler { type: "gaussian" mean: 0.1 std: 1 }
}
}
layer {
name: "L2" type: "Eltwise"
bottom: "B0" bottom: "B1" top: "B2"
eltwise_param { operation: SUM }
}
layer {
name: "L3" type: "Convolution" bottom: "B2" top: "B3"
convolution_param {
num_output: 8 pad: 1 kernel_size: 3
weight_filler { type: "gaussian" std: 0.001 }
bias_filler { type: "gaussian" mean: 0.1 std: 1 }
}
}
layer {
name: "L4" type: "Eltwise"
bottom: "B0" bottom: "B2" bottom: "B3" top: "B4"
eltwise_param { operation: SUM }
}
The network looks like this:
Here, blob B0 is input to both layers L2 and L4, but is clobbered by L2. The output B4 should ideally equal B0 + B2 + B3, but it ends up being equal to *2B2 + B3**. For now, I replaced the Eltwise layers with those from borisgin/nvcaffe-0.16, and the output is as expected.
Try commenting out the following lines in the Reshape function of Eltwise layer and see if the issue is resolved.
if (op_ == EltwiseParameter_EltwiseOp_SUM && nocoeffs) { for (int i = 0; i < bottom.size(); ++i) { bottom[i]->ShareDiff(top[0]); } top[0]->ShareData(bottom[0]); }
@venkai could you verify https://github.com/drnikolaev/caffe/tree/caffe-0.17 release candidate?
@venkai Please verify https://github.com/NVIDIA/caffe/tree/v0.17.1 release and reopen the issue if needed.
The Eltwise Layer seems to clobber the first bottom blob. This is usually not a problem, since the inputs to Eltwise layers are typically not used again in most nets. However, for some rare cases like hyper-residual nets or symmetric skip-connection based ResNets, this causes a problem.