CNN configuration for image classification

Dear all,
I hope this message finds you well.

I’m currently working on classifying X-ray data using the Cat/Dog workflow example as a reference, and I’ve encountered an issue that I could use some assistance with.

I’ve adhered to the default settings and used 4000 images for both the training and testing datasets, following the configuration used for the Cat/Dog CNN workflow. However, I consistently encounter the following error message:

“Execute failed: Node training data size for network input/target ‘input_1_0:0’ does not match the expected size. Neuron count is 67500, batch size is 128. Thus, expected training data size is 8640000. However, the node training data size is 3150000. Please check the column selection for this input/target and validate the node’s training data.”

I would greatly appreciate your guidance in resolving this issue. Any suggestions on how to adjust the CNN network configuration or other parameter selection to fix the input/target configuration issue would be extremely helpful.

The data set can be found here: Chest X-Ray Images (Pneumonia) | Kaggle

Hi @sven-abx,

I found that you faced the same issue in the past and you managed to solve the issue.

I’m using the image resize node to unify the size of the pictures I’m using to train the model, but whatever settings iI’m using, I’m still getting the same error message.

appreciate your valuable feedback and insights.

“Execute failed: Node training data size for network input/target ‘input_1_0:0’ does not match the expected size. Neuron count is 150528, batch size is 128. Thus, expected training data size is 19267584. However, node training data size is 7124992. Please check the column selection for this input/target and validate the node’s training data.”

@Kathrin , if you can also share your thoughts, that will be highly appreciated.

Regards,
Asem

Hi @aabughazaleh,

I’ve just investigated the issue a bit and the problem is connected to the fact that the images you are trying to classify only have X,Y dimensions. They lack a “Channel” dimension which is needed to correctly input the images in the Keras Input Layer, and later on for the Learner to understand the proper number of neurons to train.

This is not just a requirement of the KNIME Keras extension but a generalized requirement to train DL architectures. You can read more here, in the section “Images as 3D Arrays”.

This is how the image dimensions you’re using are:

This is how the required image dimensions should be (if you’re using gray-scaled images, your Channel usually has the value “1” instead of “3”):

Once image dimensions are fixed, the Keras Input Layer node in your workflow should have the following input shape: 150, 150, 1.

@hannan_saleem are I are investigating how to best do that in KNIME. But feel free to share the answer if you find it before us :slight_smile:.

Happy KNIMEing,
Roberto

2 Likes

Hi @roberto_cadili ,

Many thanks indeed for the feedback, it was very helpful.

at least, now we know what is the problem.

I will try to find a way to convert the images from 2D to 3D, I might use the Keras to do this conversion, as suggested by Sreya_22, in his post at Kaggle

I will update this post once I manage to find the solution.

Best regards,
Asem

1 Like

Hi @roberto_cadili,

The issue is resolved!

I found a component that converts images from Gray to RGB, which solved the issue. special thanks to @l.thomas.

Many thanks indeed for your and @hannan_saleem support in troubleshooting and explaining the root cause of the problem.

This experience serves as a clear, and real-life example of the strength and efficacy of the KNIME community. Beyond providing a platform for collaboration, KNIME community offers solutions and ready-made components that empower users to overcome their challenges.

Big thanks to everyone who contributed to solving this issue.

Regards,
Asem

3 Likes

Hi @aabughazaleh, that’s brilliant, congratulations! :slight_smile:

Totally agree with your considerations about components - and of course thanks to the author and the open-source community for sharing it!

Happy KNIMEing,
Roberto

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.