forked from phoenix104104/LapSRN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vllab_nn_L2_loss.m
33 lines (32 loc) · 1.03 KB
/
vllab_nn_L2_loss.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function Y = vllab_nn_L2_loss(X, Z, dzdy)
% -------------------------------------------------------------------------
% Description:
% L2 (MSE) loss function used in MatConvNet NN
% forward : Y = vllab_nn_L2_loss(X, Z)
% backward: Y = vllab_nn_L2_loss(X, Z, dzdy)
%
% Input:
% - X : predicted data
% - Z : ground truth data
% - dzdy : the derivative of the output
%
% Output:
% - Y : loss when forward, derivative of loss when backward
%
% Citation:
% Deep Laplacian Pyramid Networks for Fast and Accurate Super-Resolution
% Wei-Sheng Lai, Jia-Bin Huang, Narendra Ahuja, and Ming-Hsuan Yang
% IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2017
%
% Contact:
% Wei-Sheng Lai
% University of California, Merced
% -------------------------------------------------------------------------
if nargin <= 2
diff = (X - Z) .^ 2;
Y = 0.5 * sum(diff(:));
else
Y = (X - Z) * dzdy;
end
end