C-RNN regression error (Array inputs have incompatible channel dimensions)
2 ビュー (過去 30 日間)
古いコメントを表示
Hi.
I am writing a C-RNN regression learning code. The loaded "paddedData2.mat" file is saved as paddedData, and it is stored as an N X 3 cell, as shown in the attached image. The input matrix used for training is the 3rd column of paddedData, which is [440 5] double, and the regression variable is the values in the 1st column. With this, I plan to create features of size [436 1] using two [3 3] kernels of convolution and train them using LSTM. The code is as follows. When running this code, the training window pops up, and at the same time, an error message "Array inputs have incompatible channel dimensions." occurs. Is there a solution?
clc;
clear all;
load("paddedData2.mat","-mat")
XTrain = paddedData(:,3);
YTrain1 = cell2mat(paddedData(:,1));
layers = [
sequenceInputLayer([440 5 1])
convolution2dLayer(3,8)
batchNormalizationLayer
reluLayer
convolution2dLayer(3,8)
batchNormalizationLayer
reluLayer
flattenLayer
fullyConnectedLayer(100)
lstmLayer(100,'OutputMode','last')
fullyConnectedLayer(1)
regressionLayer];
options = trainingOptions('adam', ...
'MaxEpochs',2000, ...
'MiniBatchSize',100, ...
'Plots','training-progress');
net = trainNetwork(XTrain, YTrain1, layers, options);

0 件のコメント
採用された回答
Angelo Yeo
2024 年 5 月 16 日
It might be a bug in R2022a, but I'm not sure where exactly the error comes from because it uses a "builtin" function. However, it looks like the issue is fixed in a recent release. You can see that there is no issue in R2024a.
Please update to the most recent version of MATLAB and run the code.
clear;
paddedData = cell(10, 3); % Intentionally changed the #observations from 900 to 10 for reproduction purpose
paddedData(:,1) = cellfun(@(x) 405, paddedData(:,1), 'UniformOutput', false);
paddedData(:,2) = cellfun(@(x) 10, paddedData(:,2), 'UniformOutput', false);
paddedData(:,3) = cellfun(@(x) rand(440, 5), paddedData(:,3), 'UniformOutput', false)
XTrain = paddedData(:,3);
YTrain1 = cell2mat(paddedData(:,1));
layers = [
sequenceInputLayer([440 5 1])
convolution2dLayer(3,8)
batchNormalizationLayer
reluLayer
convolution2dLayer(3,8)
batchNormalizationLayer
reluLayer
flattenLayer
fullyConnectedLayer(100)
lstmLayer(100,'OutputMode','last')
fullyConnectedLayer(1)
regressionLayer];
options = trainingOptions('adam', ...
'MaxEpochs',10, ... % Intentionally changed the max epochs for reproduction purpose
'MiniBatchSize',100, ...
'Plots','none'); % Intentionally changed 'none' for reproduction purpose
net = trainNetwork(XTrain, YTrain1, layers, options);
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Build Deep Neural Networks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!