insertion of equation in classification layer of deep neural network for semantic segmetnation.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
2 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Deep Learning Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!