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

72 visualizaciones (últimos 30 días)
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
Christian Holz
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
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.

Iniciar sesión para comentar.

Respuestas (1)

Matt J
Matt J el 5 de Abr. de 2023
Editada: Matt J el 6 de Abr. de 2023
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 Image Data Workflows en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by