简体   繁体   中英

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 external appearance. I have all the necessary data, however I have a question about the following line of code.

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

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

You should not train it in any particular order, each batch should contain positive and negative examples, in a 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 produce batches sequentially. A good practice is also to reshuffle your data after each epoch, so the neural network does not see any pattern in the order that the samples are presented.

This techniques prevent any kind of bias in neural network training.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM