-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathmaeLossLayer.m
More file actions
32 lines (28 loc) · 796 Bytes
/
maeLossLayer.m
File metadata and controls
32 lines (28 loc) · 796 Bytes
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
%% L1 loss
% Author: Mahmoud Afifi
% Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
% Please cite our paper:
% Mahmoud Afifi and Michael S Brown. Deep White-Balance Editing. In CVPR, 2020.
%%
classdef maeLossLayer < nnet.layer.RegressionLayer
properties
scale
end
methods
function layer = maeLossLayer(name)
layer.Name = name;
layer.Description = 'Mean absolute error';
end
function loss = forwardLoss(layer, Y, T)
% Calculate MAE.
sz = size(Y);
if length(sz) == 3
R = 1;
else
R = sz(4);
end
loss = abs(Y-T);
loss = sum(loss(:))/R;
end
end
end