Effacer les filtres
Effacer les filtres

Error for dlarray format, but why?

8 vues (au cours des 30 derniers jours)
Song Decn
Song Decn le 1 Juin 2021
Réponse apportée : Ben le 20 Juin 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 commentaire
Matt J
Matt J le 18 Juin 2023
Modifié(e) : Matt J le 18 Juin 2023
We need to examine dims(dlX) and the sizes of all your input variables.

Connectez-vous pour commenter.

Réponses (1)

Ben
Ben le 20 Juin 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.

Catégories

En savoir plus sur Image Data Workflows dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by