Does "Define Custom Classification Output Layer" not support adding learning parameters?

1 visualización (últimos 30 días)
I want to customize a cross-entropy classification loss function. In this loss, I want to add parameters that can be learned, but after I write it out, I don’t support adding it. How can I solve it?
unknow attribute name "Learnable"???
Is it so inflexible? I hope that future versions will greatly support the freedom and flexibility of "Define Custom Layer" in many aspects! ! !
classdef myClassificationLayer < nnet.layer.ClassificationLayer
properties (Learnable) % unknow attribute name "Learnable"???
% Layer learnable parameters
% kernel parameter ,size: embedding_size*classnum, 每列代表一个“代理特征向量”
kernel
end
properties
% (Optional) Layer properties.
% Layer properties go here.
end
methods
function layer = myClassificationLayer()
% (Optional) Create a myClassificationLayer.
...
% Layer constructor function goes here.
end
function loss = forwardLoss(layer, Y, T)
% Return the loss between the predictions Y and the training
% targets T.
%
% Inputs:
% layer - Output layer
% Y – Predictions made by network
% T – Training targets
%
% Output:
% loss - Loss between Y and T
...
% Layer forward loss function goes here.
end
function dLdY = backwardLoss(layer, Y, T)
% (Optional) Backward propagate the derivative of the loss
% function.
%
% Inputs:
% layer - Output layer
% Y – Predictions made by network
% T – Training targets
%
% Output:
% dLdY - Derivative of the loss with respect to the
% predictions Y
...
% Layer backward loss function goes here.
end
end
end

Respuestas (0)

Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by