I am new to the deep learning toolbox and I am myself learning convolutional neural network (CNN). My dataset consists of 1000 RGB images of 100x40 size. Therefore, `Xdata = 1x1x1000` of data type double.

Out of these I used first 700 for training, `Xtrain = 1x1x700` of data type Image.

I am getting this error 

> 
> Error using trainNetwork (line 150)
>  Invalid training data. X must be a 4-D array of images, an ImageDatastore, or a table.
> 
> 
> 

I cannot understand how to use the table data structure and What is the proper way to input the data into CNN? Is not possible to input RGB image directly as image data type or do I need to convert each channel and feed 3 matrices of 2 D?

Please help.

```
imageSize = [100 40];

dropoutProb = 0.1;
numF = 8;
layers = [
    imageInputLayer(imageSize)

    convolution2dLayer(3,numF,'Padding','same')
    batchNormalizationLayer
    reluLayer

    maxPooling2dLayer(3,'Stride',2,'Padding','same')

    convolution2dLayer(3,2*numF,'Padding','same')
    batchNormalizationLayer
    reluLayer

    maxPooling2dLayer(3,'Stride',2,'Padding','same')

    convolution2dLayer(3,4*numF,'Padding','same')
    batchNormalizationLayer
    reluLayer

    maxPooling2dLayer(3,'Stride',2,'Padding','same')

    convolution2dLayer(3,4*numF,'Padding','same')
    batchNormalizationLayer
    reluLayer
    convolution2dLayer(3,4*numF,'Padding','same')
    batchNormalizationLayer
    reluLayer

    maxPooling2dLayer([1 13])

    dropoutLayer(dropoutProb)
    fullyConnectedLayer(numClasses)
    softmaxLayer
    classificationLayer];

miniBatchSize = 50;
validationFrequency = floor(numel(Ytrain)/miniBatchSize);
options = trainingOptions('adam', ...
    'InitialLearnRate',3e-4, ...
    'MaxEpochs',25, ...
    'MiniBatchSize',miniBatchSize, ...
    'Shuffle','every-epoch', ...
    'Plots','training-progress', ...
    'Verbose',false, ...
    'ValidationData',{XValidation,YValidation}, ...
    'ValidationFrequency',validationFrequency, ...
    'LearnRateSchedule','piecewise', ...
    'LearnRateDropFactor',0.1, ...
    'LearnRateDropPeriod',20);

  trainedNet = trainNetwork(Xtrain,layers,options);

```