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
2022년 6월 24일
Could you please share the data on which you are training the model in order to answer this
Francesco Montanaro
2022년 6월 24일
nagihan yagmur
2023년 3월 27일
Hello, I'm getting the same issue. How did you solve the problem?
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
2023년 6월 15일
Christian Holz
2023년 6월 16일
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
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개)
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 Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!