Errors related to imageInputLayer in 3D-CNN for 4D data
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Himanshu
2023-3-2
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".
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!