How to modify the function to input multi-channel images for CNN training in MATLAB 2017a?

6 visualizaciones (últimos 30 días)
Hi,
I'm trying to train a Convolutional Neural Network with the newly released functions in MATLAB 2017a.
The input consists of two gray-scale images with resolution 100*100, so I stack them as a two-channel image, thus the dimension of the image is 100*100*2.
Next, I designed the architecture of input layer as
layers = [imageInputLayer([100 100 2])
...(omit the rest)]
However, only 1 (gray-scale image) and 3 (color image) are valid for the number of channels (the third parameter in [100 100 2]).
So my settings are invalid and the error is
Error using nnet.cnn.layer.ImageInputLayer>iCheckInputSize (line 238)
Expected input image size to be a 2 or 3 element vector. For a 3-element vector, the third element
must be 3 or 1.
I will appreciate that if anybody can help to modify the built-in function, so users can input a multi-channel image, such as a 2-channel image or a 200-channel image. I've tried but got stuck.

Respuestas (3)

Zhiyi TANG
Zhiyi TANG el 27 de Mzo. de 2018
Editada: Zhiyi TANG el 27 de Mzo. de 2018
  1 comentario
hiba
hiba el 6 de Feb. de 2019
please con you explain more the sysnatxe of using imageInputLayer with 3 dimention image size [240* 240*155 ] thank yoiu

Iniciar sesión para comentar.


Muhammad Nabi
Muhammad Nabi el 26 de Mzo. de 2018
I am having the same problem I have 4 2D feature images for the same label instance so my data set is [NxMx4] and I cant use a the CNN for it
  2 comentarios
Salma Ali
Salma Ali el 25 de Mayo de 2018
Hi, I would like to use multi-input images with different sizes to CNN, is there any function in Matlab to do that? I appreciate any help. Thanks.

Iniciar sesión para comentar.


Xin Zhang
Xin Zhang el 21 de Mayo de 2018
Hi, i am trying to iunput 4 channels (RGB+Nir) to the RCNN. Thanks to your work, it seems that the input of 4 channels is possible using the 'imageInputLayer'. But I got another question of how to make the input argument'trainingData' of the function 'trainFasterRCNNObjectDetector'? It requires as 'Labeled ground truth images, specified as a table with two or more columns. The first column must contain paths and file names to grayscale or truecolor (RGB) images'. How can we make the argument 'trainingData' as 2 channels or 4 channels? Hope to get your reply soon. Best regards,

Community Treasure Hunt

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

Start Hunting!

Translated by