<commit_before># transfer-learning
> Exploring ways to learn with the least amount of labelled data by taking advantage of transfer-learning techniques.

I've set myself the challenge to classify images of my dogs using the least amount of training photos using the latest in transfer-learning techniques. 

### Meet the dogs

![Bastian](images/bastian.jpg) ![Bella](images/bella.jpg) ![Grace](images/grace.jpg) ![Pablo](images/pablo.jpg)

Who wouldn't want to train on them? :-)


## Option 1: Fine-tune existing custom model

The idea is to fine-tune a model trained on a large publicly available data set. I chose the Kaggle cats vs. dogs data set with 25000 images (12500 cats, 12500 dogs) hoping that my model will learn enough about the features that are unique to dogs to be able to fine tune the model on a small set of my dog images.

### The Architecture

For the base model I have gone for a simple 5 layer convolutional neural network, each layer is made up of a convolutional layer followed by a max pool layer. Using 20000 of the training images you should be able to get about 85%+ accuracy before some serious overfitting kicks in.

![Architecture](images/transfer-learning-custom-model.png)

As can be seen from the diagram the bottom 4 layers are transferred and locked, and fine-tuning is done on a single convolutional layer followed by a max pool layer feeding into a fully connected layer which in turn feeds into a 4-class softmax layer.


## Using the code

### Dependencies:

* Python 3.5
* numpy
* scikit-learn
* matplotlib
* tensorflow (1.1)

### Folder structure:

Create the following folder structure:

transfer-learning
(the source code lives here)
|

|----data (the train/test data lives here)

|

|----tf_logs (the TensorBoard logs lives here)

Download the cats vs. dogs dataset from [here](https://www.kaggle.com/c/dogs-vs-cats-redux-kernels-edition/data) and extract into a folder called *train* under the *data* folder.
<commit_msg>Updated folder structure<commit_after># transfer-learning
> Exploring ways to learn with the least amount of labelled data by taking advantage of transfer-learning techniques.

I've set myself the challenge to classify images of my dogs using the least amount of training photos using the latest in transfer-learning techniques. 

### Meet the dogs

![Bastian](images/bastian.jpg) ![Bella](images/bella.jpg) ![Grace](images/grace.jpg) ![Pablo](images/pablo.jpg)

Who wouldn't want to train on them? :-)


## Option 1: Fine-tune existing custom model

The idea is to fine-tune a model trained on a large publicly available data set. I chose the Kaggle cats vs. dogs data set with 25000 images (12500 cats, 12500 dogs) hoping that my model will learn enough about the features that are unique to dogs to be able to fine tune the model on a small set of my dog images.

### The Architecture

For the base model I have gone for a simple 5 layer convolutional neural network, each layer is made up of a convolutional layer followed by a max pool layer. Using 20000 of the training images you should be able to get about 85%+ accuracy before some serious overfitting kicks in.

![Architecture](images/transfer-learning-custom-model.png)

As can be seen from the diagram the bottom 4 layers are transferred and locked, and fine-tuning is done on a single convolutional layer followed by a max pool layer feeding into a fully connected layer which in turn feeds into a 4-class softmax layer.


## Using the code

### Dependencies:

* Python 3.5
* numpy
* scikit-learn
* matplotlib
* tensorflow (1.1)

### Folder structure:

Create the following folder structure:


|transfer-learning (the source code lives here)

|

|----data (the train/test data lives here)

|

|----tf_logs (the TensorBoard logs lives here)

Download the cats vs. dogs dataset from [here](https://www.kaggle.com/c/dogs-vs-cats-redux-kernels-edition/data) and extract into a folder called *train* under the *data* folder.

{'fraction_non_alphanumeric': 0.07312753036437247, 'fraction_numerical': 0.015182186234817813, 'mean_word_length': 4.263648468708388, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1608040', 'n_tokens_mistral': 1145, 'n_tokens_neox': 1057, 'n_words': 560}