Applying Transfer Learning on Dogs vs Cats Dataset (ResNet18) using PyTorch C++ API

Transfer Learning – Before we go ahead and discuss the Why question of Transfer Learning, let’s have a look at What is Transfer Learning? Let’s have a look at the Notes from CS231n on Transfer Learning: In practice, very few people train an entire Convolutional Network from scratch (with random initialization), because it is relatively rare to have a dataset of sufficient size. Instead, it is common to pretrain a ConvNet on a very large dataset (e.g. ImageNet, which contains 1.2 million images with 1000 categories), and then use the ConvNet either as an initialization or a fixed feature extractor for the task of interest. ...

August 16, 2019 · 8 min · Kushashwa Ravi Shrimali

Classifying Dogs vs Cats using PyTorch C++: Part 2

In the last blog, we had discussed all but training and results of our custom CNN network on Dogs vs Cats dataset. Today, we’ll be making some small changes in the network and discussing training and results of the task. I’ll start with the network overview again, where we used a network similar to VGG-16 (with one extra Fully Connected Layer in the end). While there are absolutely no problems with that network, but since the dataset contains a lot of images (25000 in training dataset) and we were using (200x200x3) input shape to the network (which is 120,000 floating point numbers), this leads to high memory consumption. In short, I was out of RAM to store these many images during program execution. ...

July 31, 2019 · 7 min · Kushashwa Ravi Shrimali

Classifying Dogs vs Cats using PyTorch C++ API: Part-1

Hi Everyone! So excited to be back with another blog in the series of PyTorch C++ Blogs. Today, we are going to see a practical example of applying a CNN to a Custom Dataset - Dogs vs Cats. This is going to be a short post of showing results and discussion about hyperparameters and loss functions for the task, as code snippets and explanation has been provided here, here and here. ...

July 23, 2019 · 7 min · Kushashwa Ravi Shrimali

Training a Network on Custom Dataset using PyTorch C++ API

Recap of the last blog Before we move on, it’s important what we covered in the last blog. We’ll be going forward from loading Custom Dataset to now using the dataset to train our VGG-16 Network. Previously, we were able to load our custom dataset using the following template: ...

July 5, 2019 · 4 min · Kushashwa Ravi Shrimali

Announcing a series of blogs on PyTorch C++ API

I’m happy to announce a Series of Blog Posts on PyTorch C++ API. Check out the blogs in the series here. Happy Reading!

July 4, 2019 · 1 min · Kushashwa Ravi Shrimali

Custom Data Loading using PyTorch C++ API

Overview: How C++ API loads data? In the last blog, we discussed application of a VGG-16 Network on MNIST Data. For those, who are reading this blog for the first time, here is how we had loaded MNIST data: auto data_loader = torch::data::make_data_loader<torch::data::samplers::SequentialSampler>( std::move(torch::data::datasets::MNIST("../../data").map(torch::data::transforms::Normalize<>(0.13707, 0.3081))).map( torch::data::transforms::Stack<>()), 64); Let’s break this piece by piece, as for beginners, this may be unclear. First, we ask the C++ API to load data (images and labels) into tensors. ...

July 2, 2019 · 8 min · Kushashwa Ravi Shrimali

Introduction to PyTorch C++ API: MNIST Digit Recognition using VGG-16 Network

Environment Setup [Ubuntu 16.04, 18.04] Note: If you have already finished installing PyTorch C++ API, please skip this section. Download libtorch: CPU Version: wget https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-latest.zip -O libtorch.zip GPU Version (CUDA 9.0): wget https://download.pytorch.org/libtorch/cu90/libtorch-shared-with-deps-latest.zip -O libtorch.zip GPU Version (CUDA 10.0): wget https://download.pytorch.org/libtorch/cu100/libtorch-shared-with-deps-latest.zip Unzip libtorch.zip: unzip libtorch.zip We’ll use the absolute path of extracted directory (libtorch) later on. Implementation The VGG-16 Network is shown in the Figure below. We’ll start of by first including libtorch header file. ...

June 7, 2019 · 3 min · Kushashwa Ravi Shrimali