- https://www.mathworks.com/help/deeplearning/ref/nnet.cnn.layer.sequenceinputlayer.html
- https://www.mathworks.com/help/matlab/ref/double.reshape.html
- https://www.mathworks.com/help/deeplearning/ref/trainnetwork.html#mw_36a68d96-8505-4b8d-b338-44e1efa9cc5e
error :Error using trainNetwork Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that dimension.
2 ビュー (過去 30 日間)
古いコメントを表示
I'm tryng to develop a 1D convolutional autoencoder:
layers=[ sequenceInputLayer(128)
convolution1dLayer(4,64,padding='same')
convolution1dLayer(4,32,padding='same')
transposedConv1dLayer(4,32,cropping="same")
transposedConv1dLayer(4,64,cropping="same")
convolution1dLayer(128,1,padding='same')
regressionLayer
];
options = trainingOptions('adam', ...
'InitialLearnRat',1e-4,...
'MaxEpochs',1280, ...
'MiniBatchSize',128, ...
Plots="training-progress");
net = trainNetwork(DATA_OUT,DATA_IN,layers,options);
YP=predict(net,DATA_OUT(:,10));
the size of the DATA_OUT and DATA_IN is 128 x 1280, running the program the following error occures:
Error using trainNetwork
Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate
size for that dimension.
Error in CAE_MATLAB (line 78)
net = trainNetwork(DATA_OUT,DATA_IN,layers,options);
Caused by:
Error using reshape
Number of elements must not change. Use [] as one of the size inputs to automatically calculate the
appropriate size for that dimension.
Does anyone can help?
Many Thanks
0 件のコメント
回答 (1 件)
Soumya
2025 年 6 月 13 日
編集済み: Soumya
2025 年 6 月 13 日
I encountered a similar issue when training the 1D convolutional autoencoder in MATLAB. It is due to a mismatch between the shape of the input data and what the ‘sequenceInputLayer’ expects. Specifically, ‘sequenceInputLayer(128)’ expects the input data to be a 3D array of the format [h, c, s] where h is the height (features), c is the number of channels, and s is the sequence length. Since the data ‘DATA_OUT’ and ‘DATA_IN’ are sized 128 x 1280, we need to reshape them to include the channel dimension before training. This can be done by using the ‘reshape’ function. The following code snippet shows how the issue can be resolved:
DATA_OUT_reshaped = reshape(DATA_OUT, [128, 1, 1280]);
DATA_IN_reshaped = reshape(DATA_IN, [128, 1, 1280]);
The following documentation link provides detailed information on the relevant topics:
I hope this helps!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!