Update a parameter which is not learnable in Custom Layers Deep Learning
Mostrar comentarios más antiguos
Hello,
I am working on a deep learning project in which I use a custom layer. In this layer, I have a parameter, α, that depend of the weight. I want to update when the weight is updated thus, for me, α is not a learnable parameter. Here is my predict function :
function [Z] = predict(layer, X)
% Z = predict(layer, X1, ..., Xn) forwards the input data X1,
% ..., Xn through the layer and outputs the result Z.
B=layer.Bias;
W = layer.Weights;
numel=size(X,2);
% Initialize output
Z = zeros(layer.OutputSize,numel,"single");
%alpha coef calculation
e=zeros(1,layer.InputSize);
numel=size(X,2);
for j= 1:size(layer.Graphe.neighbors(layer.TargetNode))
for i=1:numel
e(:,j)=mean(e(:,j)+W(:,layer.TargetIndex)*X(layer.TargetIndex,i)+W(:,j)*X(j,i),1);
end
end
e=leakyRELU(e,0.2);
A=softmax(e');
A=A';
layer.Alpha=A;
% Weighted addition
Z=(A.*W)*X+B;
end
Alpha is declared as a parameter here
properties
InputSize
OutputSize
TargetNode
Graphe
TargetIndex
Alpha
end
However when my training ends net.layer(3,1).Alpha gives me the initial value of α and it is the same thing in the backward function.
How can I do to update α ?
Thank you in advance for your futur help.
Mathieu
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Deep Learning Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!