Skip to main content

Day 6 (7/15/19): Transfer Learning with CUB-200

Today I started practicing transfer learning with CNNs. This process involves pretraining a CNN on a very large dataset (e.g. ImageNet, which contains 1.2 millions images with 1000 categories) and then using that pretrained model either as an initialization or a fixed feature extractor for a new task (e.g. classify images from a new dataset). This technique is actually much more widely used in practice than training a CNN from scratch because it is rare to have a dataset of sufficient size to fit your task and training a model on a dataset like ImageNet would take weeks. 


The dataset I started working with is called Caltech-UCSD Birds 200 (CUB-200) which contains images representing 200 different species of birds. First, I loaded the dataset and split the data into train and test sets. Using the transform function I implemented data augmentation, a strategy to significantly increase the diversity of data without actually collecting new data. Then, using pytorch, I loaded a pretrained Resnet18 model (a residual network with 18 layers) and trained only the weights of the fully connected layer and the linear classifier (I used a LogSoftmax). Using a Cross Entropy Loss Function and Adam Optimizer this new fine-tuned network achieved ~60% accuracy classifying the CUB-200 images.



After training, I took a sample of the test data to visualize how the model's predictions were matching up. While the network was not quite as accurate as I would have hoped, it did get very close to predicting the right species even when it was misclassified. For example, numerous instances occurred of the model predicting a Sooty Albatross when it was supposed to be a Black-footed Albatross (try to guess which is which from the two images below). Given that not all of the image data was very clear in detail (and the transformations for data augmentation sometimes cropped out parts of the bird) it is not surprising that many of the images were misclassified. 






I'm excited to start learning more about how to implement CNNs and tweak their structures and parameters to achieve better results and generalize to different datasets.

Comments

Popular posts from this blog

Day 29 (8/15/19): Final Day Before Presentations

Most of today was also spent practicing and editing my presentation to make it as professional as I can. I'm really looking forward to the opportunity to present my work to faculty and friends tomorrow. Here is a link to the slides for my final presentation: Novelty Detection in Streaming Learning using Neural Networks

Day 28 (7/14/19): Presentation Dry Run

In the morning, all of us interns got the chance to practice our presentations in front of each other in the auditorium. I was pretty happy with how mine went overall but the experience was definitely valuable in identifying typos or slight adjustments that should be made. Throughout the rest of the day, I tried to implement these changes and clean up a few plots that I want to include for Friday.