AlexOlsen / DeepWeeds

A Multiclass Weed Species Image Dataset for Deep Learning
https://www.nature.com/articles/s41598-018-38343-3
Apache License 2.0
199 stars 85 forks source link

Paper details clarification #5

Closed kleysonr closed 4 years ago

kleysonr commented 5 years ago

Hi Alex,

This is really a very good work. Congrats !!

I would like to ask you some help to understand 2 points in your work.

1) I’m a little bit confused because you are using transfer learning, and I saw in other works that for transfer learning in general we only train a new 'top'. But you make all the layers from the pre-trained ResNet ‘trainable’ and then train the model for just two single epochs. How could just two epochs give you a good accuracy with only aprox. 1k images per class training the full network? Also, there is just a single Dense layer resposible for the prediction (binary_crossentropy).

2) You are using a ‘negative’ class. But the number of negative examples is bigger than the total of all the other classes. If someone decide to use a negative class as well, how to calculate (or balance) the negative class with the other classes ?

Best Regards. Kleyson Rios.

AlexOlsen commented 4 years ago

Hi Kleyson. Thanks for your comment. Here's my (very) late response to your questions.

  1. Transfer learning is not limited to fine-tuning just the "top" of the pre-trained network. You have the option of freezing or not freezing any combination of layers during the transfer learning process. As nicely described in Stanford's CS231n course notes on Transfer Learning (http://cs231n.github.io/transfer-learning/), your choice for either fine tuning the top of the network, or using the pre-trained weights as a starting point to fine tune the entire network depends on the size of the new dataset and how different the new learning problem is. Because of the sufficient size of our dataset and the difference in learning nature between specific weeds and varied ImageNet classes, I decided to fine-tune through the entire network.

  2. You are correct, there is major class imbalance in this dataset. However, this class imbalance is true for the nature of the learning problem for weed classification in the field. With no method of balancing the classes, strong classification accuracy was achieved. And to maximise performance in the field, I chose to keep the class distribution consistent.

As an aside, I experimented with addressing the class imbalance by weighting the loss function proportionately by using the "class_weight" argument for the "fit_generator" Keras function. (*This is one such method for balancing other classes with the negative class). This resulted in slightly less accurate recall of the Negative class and slightly better classification of the weed classes, with a negligible net accuracy. However when deployed in the field, the original imbalanced model performed much better. This confirmed my heuristic that for best in-field performance, your dataset should exhibit the same class distribution as seen in the field.