Borrar filtros
Borrar filtros

Error for dlarray format, but why?

8 visualizaciones (últimos 30 días)
Song Decn
Song Decn el 1 de Jun. de 2021
Respondida: Ben el 20 de Jun. de 2023
K>> lstm(dlX, hiddenState, initialCellState, inputWeights, ...
recurrentWeights, bias)
Error using deep.internal.dlarray.validateWeights (line 9)
'U' dimension (if not a formatted dlarray, second dimension) of weights must have size
NumFeatures, where NumFeatures is the size of the 'C' dimension of the input data.
Can any expert help me to solve this issue? Also I am still quite confused about the concept with the format labels C S T U B
Is there any simple explanation for tutorial for their usage?
Many thks
  1 comentario
Matt J
Matt J el 18 de Jun. de 2023
Editada: Matt J el 18 de Jun. de 2023
We need to examine dims(dlX) and the sizes of all your input variables.

Iniciar sesión para comentar.

Respuestas (1)

Ben
Ben el 20 de Jun. de 2023
This error appears to be thrown if the inputWeights have the wrong size, e.g. you can take this example code from help lstm
numFeatures = 10;
numObservations = 32;
sequenceLength = 64;
X = dlarray(randn(numFeatures,numObservations,sequenceLength), 'CBT');
% Create formatted dlarrays for the lstm parameters with three
% hidden units.
numHiddenUnits = 3;
H0 = dlarray(randn(numHiddenUnits,numObservations),'CB');
C0 = dlarray(randn(numHiddenUnits,numObservations),'CB');
weights = dlarray(randn(4*numHiddenUnits,numFeatures),'CU');
recurrent = dlarray(randn(4*numHiddenUnits,numHiddenUnits),'CU');
bias = dlarray(randn(4*numHiddenUnits,1),'C');
% Apply an lstm calculation
[Y,hiddenState,cellState] = lstm(X,H0,C0,weights,recurrent,bias);
If you now make weights the wrong size in the 2nd dimension you get the error:
errorWeights = dlarray(randn(4*numHiddenUnits,numFeatures+1),'CU');
lstm(X,H0,C0,errorWeights,recurrent,bias); % throws error
This suggests your inputWeights have the wrong size to use lstm. The inputWeights require a size of 4*NumHiddenUnits x NumFeatures, and they can either be a dlarray with format labels or without:
% both of these are valid - the format label U is just to specify that this
% dimension doesn't correspond to any of the standard named labels S -
% spatial, C - channel, T - time, B - batch.
weights = dlarray(randn(4*numHiddenUnits,numFeatures),'CU');
weights = dlarray(randn(4*numHiddenUnits,numFeatures));
If you list the sizes as @Matt J says then we can debug the issue further.

Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by