필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
RU
RU 2023년 2월 20일
댓글: RU 2023년 3월 3일
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.

답변 (1개)

Himanshu
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".
  댓글 수: 1
RU
RU 2023년 3월 3일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by