Error on convolutional layer's: input data has 0 spatial dimensions and 0 temporal dimensions.
Mostrar comentarios más antiguos
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 comentarios
Siraj
el 24 de Jun. de 2022
Could you please share the data on which you are training the model in order to answer this
Francesco Montanaro
el 24 de Jun. de 2022
nagihan yagmur
el 27 de Mzo. de 2023
Hello, I'm getting the same issue. How did you solve the problem?
Christian Holz
el 15 de Jun. de 2023
Hello, I am getting the same issue, too. I would be pleased to hear about a possible solution.
Matt J
el 15 de Jun. de 2023
Christian Holz
el 16 de Jun. de 2023
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
el 16 de Jun. de 2023
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.
Respuestas (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);
Categorías
Más información sobre Deep Learning Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!