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

1 回表示 (過去 30 日間)
Raza Ali
Raza Ali 2020 年 10 月 5 日
コメント済み: Raza Ali 2020 年 10 月 6 日
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 件のコメント
Mohammad Sami
Mohammad Sami 2020 年 10 月 5 日
I am not sure what is your question ?
Raza Ali
Raza Ali 2020 年 10 月 6 日
I want to implement the above mentioned equation in classification layer

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by