insertion of equation in classification layer of deep neural network for semantic segmetnation.

조회 수: 1 (최근 30일)
I need to implement the following equation in the classification layer.
Equation:
d(t,x) is Euclidean distance between x and t.
code for classfication layer
%%%%%%%%%%%%%%%
classdef ClassificationLayer < nnet.layer.ClassificationLayer
properties
%
end
methods
function layer = ClassificationLayer(name)
% l
l
% Set layer name.
layer.Name = name;
end
% Set layer description
layer.Description = ' cross entropy loss';
end
function loss = forwardLoss(layer, Y, T)
% loss = forwardLoss(layer, Y, T) returns the cross entropy loss between the predictions Y and the training targets T.
N = size(Y,4);
Y = squeeze(Y);
T = squeeze(T);
prod = T.*log(Y));
loss = -sum(prod(:))/N;
end
function dLdY = backwardLoss(layer, Y, T)
% dLdX = backwardLoss(layer, Y, T) returns the derivatives of the cross entropy loss with respect to the predictions Y.
Y = squeeze(Y);
T = squeeze(T);
dLdY = -(T./Y)/N;
end
end
end

답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by