Errors related to imageInputLayer in 3D-CNN for 4D data
5 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Himanshu
on 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".
See Also
Categories
Find more on AI for Signals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!