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!