In what order do I train my CNN

I am currently training a convolutional neural network to classify between a rotten apple and a normal apple based on appearance. I have all the necessary data, however I have a question about the next line of code.

epoch_x, epoch_y = tf.train.batch([resized_image, "Normal"], batch_size=batch_size)

This transmits the neural network of images and tags. My question is, should I train the network with all batches of regular oranges, and then train the neural network with rotten oranges? Should I alternate training in batches of rotten and normal oranges? Is there a specific order in which these images should be trained?

+4
source share
1 answer

You should not train him in any particular order, each batch should contain positive and negative examples in random order. If your classes are balanced, then each batch will have approximately the same number of positive / negative samples.

The easiest way to do this is to randomly shuffle your data (in the first dimension), and then sequentially produce batches. It is also good practice to rearrange your data after each era, so the neural network does not see any pattern in the order in which the samples are presented.

These methods prevent any bias in training the neural network.

+6
source

Source: https://habr.com/ru/post/1668843/


All Articles