Errors related to imageInputLayer in 3D-CNN for 4D data

5 visualizzazioni (ultimi 30 giorni)
RU
RU il 20 Feb 2023
Commentato: RU il 3 Mar 2023
I am trying to do a 3D-CNN on 4D data.
The data is as a 4D mat file of 182x218x182x3.
An example of a 4D mat file can be downloaded from the following URL;
https://www.dropbox.com/t/oklkb45udJOWz8Cc
I have created an image object in ImageDatastore.
The layers of the 3D-CNN are as follows;
layers = [
image3dInputLayer([182 218 182 3],"Name","input")
convolution3dLayer([3 3 3],8,"Name","conv3d","Padding","same")
batchNormalizationLayer("Name","batchnorm")
reluLayer("Name","relu")
maxPooling3dLayer([2 2 2],"Name","maxpool3d","Padding","same","Stride",[2 2 2])
convolution3dLayer([3 3 3],16,"Name","conv3d_1","Padding","same")
batchNormalizationLayer("Name","batchnorm_1")
reluLayer("Name","relu_1")
maxPooling3dLayer([2 2 2],"Name","maxpool3d_1","Padding","same","Stride",[2 2 2])
convolution3dLayer([3 3 3],32,"Name","conv3d_2","Padding","same")
batchNormalizationLayer("Name","batchnorm_2")
reluLayer("Name","relu_2")
maxPooling3dLayer([2 2 2],"Name","maxpool3d_2","Padding","same","Stride",[2 2 2])
fullyConnectedLayer(10,"Name","fc")
softmaxLayer("Name","softmax")
classificationLayer("Name","classoutput")];
I specified the workspace ImageDatastore as the data source.
When I run the training, I get the following error;
"Input layer valid for 3-D images only. Use imageInputLayer instead."
I do not understand the cause of the error.
Can you please tell me?
Thank you in advance.

Risposte (1)

Himanshu
Himanshu il 2 Mar 2023
Hello,
As per my understanding, you are facing an error while training the network with your specified architecture. The error occurs due to the use of "image3dInputLayer" for the input data.
The "image3dInputLayer" is used for 3D images and as per your description, you are using 4D images as input. You should use the "imageInputLayer" instead, which is designed to handle multi-channel images of arbitrary dimensions.
You can change the code for input layer as follows:
imageInputLayer([182 218 182 3],"Name","input")
You can refer to the below documentation to understand more about the "imageInputLayer".
  1 Commento
RU
RU il 3 Mar 2023
Hello,
Thank you so much for taking the time to answer my question!
imageInputLayer([182 218 182 3],"Name","input")
I executed the above code as you taught me.
However, I got the following error: "The size of the input image will be a 2 or 3 element vector.".
I think this is due to the fact that the input is 4-dimensional.
Is it possible to read 4 dimensions in imageInputLayer as well?
I am using MATLAB R2022b.
I would appreciate it if you could let me know.
Thank you in advance.

Accedi per commentare.

Categorie

Scopri di più su AI for Signals in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by