Does "Define Custom Classification Output Layer" not support adding learning parameters?
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!