Hi all,
I'm not used to develop code with CPU optimization and this is why I'm a bit lost when I try to understand the code in euclidean_loss_layer.cpp. I need help to understand what is done in this file and make my own loss layer :).
I understand that the goal is to compte diff_ which contains the loss_weight.
To compute diff_, the forward pass in Forward_cpu function computes the table of the difference between the predicted values and the ground truths (the number depends on the batch size). Right? :)
This table is stored in diff_. Why?
Then, the dot and loss values are computed and the loss value is stored in top[0]->mutable_cpu_data()[0].
For the backward pass, I don't really understand what is happening.
- const Dtype sign = (i == 0) ? 1 : -1;
- Why is the sign negative when computing gradients with respect to the label inputs?
- const Dtype alpha = sign * top[0]->cpu_diff()[0] / bottom[i]->num();
- Finally, the loss weight is computed with: bottom[i]->mutable_cpu_diff() = alpha * diff_.cpu_data()
- diff_.cpu_data() is the table of the difference computed in the forward pass, right?
As you can see, the backward process is still obscure for me.
Thanks in advance for your help!
Best,
Yoann