In Place Computation for ReLU with slope when x < 0 seems to do backprop wrong.
It seems that in place computation is not possible with ReLU when there is a negative slope for when x < 0. The reason is for the following code:
top_data[i] = std::max(bottom_data[i], Dtype(0)) + negative_slope * std::min(bottom_data[i], Dtype(0));
If negative_slope is negative, then top_data will always be positive. Since top_data== bottom_data then bottom_data will always be positive. Therefore, during backprop
bottom_diff[i] = top_diff[i] * ((bottom_data[i] > 0) + negative_slope * (bottom_data[i] <= 0));
it will always say that bottom_data[i] > 0 when, in fact, this may not always be the case.
Did you take into account that, if top==bottom, during forward, bottom_data is backed up with caffe_copy(count, bottom_data, bottom_memory_.mutable_cpu_data()); and during backward, it is re-assigned using bottom_data = bottom_memory_.cpu_data();
I am a contributor of PReLU implementation. Thanks for suggesting possible bug in PReLU and ReLU, however, I also have the same question with @sontran. If you already have numerical results that show wrong computation, it would be helpful to discuss about it.
At first I didn't, I apologize for that, but I noticed that part and modified the issue. I still believe it is an issue with the ReLU layer.
Probably ReLULayer doesn't expect to take negative negative_slope.