Error when using Convolutional Layer: Message: New shape length doesn't match original length

User: "Friedemann"
New Altair Community Member
Updated by Jocelyn
Hi,

I am trying to setup a simple Deep Learning process using the Deep Learning extension and the MNIST dataset as CSVs of grey values from Kaggle. If I just use two fully connected layers inside the Deep Learning operator everything works, but as soon as I add a convolutional layer and a pooling layer, the apply model steps fails with an error message:

Exception: org.nd4j.linalg.exception.ND4JIllegalStateException
Message: New shape length doesn't match original length: [0] vs [6584816]. Original shape: [8399, 784] New Shape: [33601, 0, 784]

The test dataset is the result of a split operator which is used to have 80% (33601 records)  of the data as training data and 20% (8399 records) as test data.

What am I doing wrong? Any help is highly appreciated
Friedemann

Find more posts tagged with

Sort by:
1 - 1 of 11
    User: "Mate"
    New Altair Community Member
    Accepted Answer
    Updated by Mate
    Well, I have never used a dataset where 3-channel (e.g.: RGB) images were put into a single array, but I did conduct a little test now:

    this is one of the MNIST images reduced to 4x4 and converted to 3-channel image (I stopped the process and looked directly at the data, how those MNIST png images look like under the hood, so this is now not the ExampleSet use-case, but rather the tutorial process where we deal with actual images files):

    that means, the tensor is 4D because we are always talking about a collection of samples (in this case a single image), and the 3D tensor inside will contain 2D matrices for each channel/depth.
    That means, this is the desired format which I'd like to get to, if I do convert my manual data set to a 3-channel one, as I did for 1-channel in my previous message.

    3 channels:
    [[0, 1.0000, 0, 0, 1.0000, 0, 0, 1.0000, 0, 0, 2.0000, 0, 0, 2.0000, 0, 0, 2.0000, 0, 0, 3.0000, 0, 0, 3.0000, 0, 0, 3.0000, 0]]

    becomes

    [[[[         0,    1.0000,         0], 
       [         0,    1.0000,         0], 
       [         0,    1.0000,         0]], 

      [[         0,    2.0000,         0], 
       [         0,    2.0000,         0], 
       [         0,    2.0000,         0]], 

      [[         0,    3.0000,         0], 
       [         0,    3.0000,         0], 
       [         0,    3.0000,         0]]]]

    So, this is a 3x3x3 image (height: 3, width: 3, depth/channel: 3).

    As you can see, if you put your data in a row, in the right order (first channel, second channel, third channel) and do set the correct Input Shape parameter for the network operator, you can even deal with multi-channel images sitting in a single ExampleSet row.