Error on convolutional layer's: input data has 0 spatial dimensions and 0 temporal dimensions.

I'm building a Deep Learning model for regression. My training data is composed of 1512 samples of 512 numeric features.
disp(size(X_train)); % 1512x512
disp(size(Y_train)); % 1512x3
layers = [
featureInputLayer(size(X_train, 2))
convolution1dLayer(3, 20)
tanhLayer()
averagePooling1dLayer(2)
convolution1dLayer(3, 10)
tanhLayer()
averagePooling1dLayer(2)
flattenLayer()
fullyConnectedLayer(20)
tanhLayer()
fullyConnectedLayer(10)
tanhLayer()
fullyConnectedLayer(3)
tanhLayer()
regressionLayer()
];
opts = trainingOptions('adam', ...
'MaxEpochs',200, ...
'Shuffle','every-epoch', ...
'Plots','training-progress', ...
'Verbose',false);
net = trainNetwork(X_train, Y_train, layers, opts);
However, I get the following error on the first convolutional layer:
Layer 'conv_layer_1': Input data must have one spatial dimension only, one temporal dimension only, or one of each. Instead, it has 0 spatial dimensions and 0 temporal dimensions.

7 件のコメント

Siraj
Siraj 2022 年 6 月 24 日
Could you please share the data on which you are training the model in order to answer this
Yes, here you are.
nagihan yagmur
nagihan yagmur 2023 年 3 月 27 日
Hello, I'm getting the same issue. How did you solve the problem?
Christian Holz
Christian Holz 2023 年 6 月 15 日
Hello, I am getting the same issue, too. I would be pleased to hear about a possible solution.
Matt J
Matt J 2023 年 6 月 15 日
@Christian Holz, @nagihan yagmur Why not try the proposed solution below?
Hello, thanks for the tip.
Unfortunately, I have not been able to solve it yet.
The application is not exactly the same for me. Therefore, here is the code excerpt from the network architecture.
The aim of this codepart is to reduce the input number to num (fc-layer) and to perform a combined probability of the number of possibilities (num) with the help of the softmaxLayer and to output the corresponding most probable or highest value with the help of the maxPooling1dLayer.
...
num = 10;
tempLayers = [
fullyConnectedLayer(num,"Name","fc_1")
layerNormalizationLayer("Name","class_layernorm_1")
softmaxLayer("Name","softmax_1")
maxPooling1dLayer(num,"Name","maxPooling_1"];
lgraph = addLayers(lgraph,tempLayers);
...
Christian Holz
Christian Holz 2023 年 6 月 16 日
Error using trainNetwork
Invalid network.
Caused by:
Layer 'maxPooling_1': Input data must have one spatial dimension only, one temporal dimension only, or one of each. Instead, it has 0 spatial dimensions and 0 temporal dimensions.

サインインしてコメントする。

回答 (1 件)

Matt J
Matt J 2023 年 4 月 5 日
編集済み: Matt J 2023 年 4 月 6 日
So far, I have only managed to work around the problem by reformulating the training inputs as 2D images of dimension 512x1:
X_train=rand(512,1,1,1512);
Y_train=rand(1512,3);
layers = [
imageInputLayer([512, 1]);
convolution2dLayer([3,1], 20)
tanhLayer()
averagePooling2dLayer([2,1])
convolution2dLayer([3,1], 10)
tanhLayer()
averagePooling2dLayer([2,1])
flattenLayer()
fullyConnectedLayer(20)
tanhLayer()
fullyConnectedLayer(10)
tanhLayer()
fullyConnectedLayer(3)
tanhLayer()
regressionLayer()
];
analyzeNetwork(layers)
opts = trainingOptions('adam', ...
'MaxEpochs',5, ...
'Shuffle','every-epoch', ...
'Plots','training-progress', ...
'Verbose',false, ...
'ExecutionEnvironment','cpu');
net = trainNetwork(X_train, Y_train, layers, opts);

カテゴリ

ヘルプ センター および File ExchangeDeep Learning Toolbox についてさらに検索

製品

リリース

R2022a

タグ

質問済み:

2022 年 6 月 24 日

コメント済み:

2023 年 6 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by