Variable changes unwantedly during repeated run
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I am currently trying to build a custom Neural Network using the Deep Network Designer and was getting an error message for one of my custom layers.
In said layer I want to multiply its input + bias with the weight matrix, but for some reason after a couple cycles the input vector changes its size so that the product can't be calculated.
The layer is the following
classdef weightedAdditionLayer < nnet.layer.Layer
% Example custom weighted addition layer.
properties
inputsize
outputsize
end
properties (Learnable)
Weights
end
methods
function layer = weightedAdditionLayer(a,b,name)
% Set layer name.
layer.Name = name;
% Set layer description.
layer.Description = "Weighted addition of inputs";
layer.inputsize = a;
layer.outputsize = b;
% Initialize layer weights.
layer.Weights = rand(layer.inputsize,layer.outputsize);
end
function Z = predict(layer, X)
Z = layer.Weights.' * [1;X(:)];
end
end
end
The vector that changes size is [1;X(:)], which goes from the wanted (201 x 1) to (12513 x 1) after approx. 6 cycles every time.
Could there be any reason in and/or outside of the code that causes this behaviour?
4 comentarios
Tarunbir Gambhir
el 24 de Mayo de 2021
Can you try training your network using a dlarray with correct data format. You can convert your training data to dlarray and specify the data format, then use this dlarray for network training.
Respuestas (0)
Ver también
Categorías
Más información sobre Deep Learning Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!