How to add new properties (layer name) in DlconvOp.m in deep network training
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Y.Yang
am 7 Feb. 2021
Beantwortet: Srivardhan Gadila
am 10 Feb. 2021
Hi,
Thanks for the new feature of custom layer backward function which allow me to add my new functions during the training of deep convolutional neural network. In the DlconvOp.m file, there are for properties {paddingSize,stride,dilation,numGroups}; How to add a new property such as current layer index or layer name in the function so I can update my weights according?
0 Kommentare
Akzeptierte Antwort
Srivardhan Gadila
am 10 Feb. 2021
"Name" is already a property of the custom layer whereas you can define the "Index" property under the Optional Properties. You can do something like below:
classdef myLayer < nnet.layer.Layer
properties
% (Optional) Layer properties.
LayerIndex
% Layer properties go here.
end
properties (Learnable)
% (Optional) Layer learnable parameters.
% Layer learnable parameters go here.
end
methods
function layer = myLayer(layerName, layerIndex)
% (Optional) Create a myLayer.
% This function must have the same name as the class.
% Layer constructor function goes here.
layer.Name = layerName;
layer.LayerIndex = layerIndex;
end
function [Z1, …, Zm] = predict(layer, X1, …, Xn)
% Layer forward function for prediction goes here.
end
function [dLdX1, …, dLdXn, dLdW1, …, dLdWk] = ...
backward(layer, X1, …, Xn, Z1, …, Zm, dLdZ1, …, dLdZm, memory)
% (Optional) Backward propagate the derivative of the loss
% function through the layer.
end
end
end
And use it as follows:
MyLayer = myLayer("MyCustomLayer",1)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Data Workflows finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!