Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CIFAR10 Custom PyTorch Model with Fast.AI Learner
{
"cells": [
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
"# Put these at the top of every notebook, to get automatic reloading and inline plotting\n",
"%reload_ext autoreload\n",
"%autoreload 2\n",
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
"import os.path\n",
"\n",
"import torch\n",
"import torch.nn as nn\n",
"import torch.nn.functional as F"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [],
"source": [
"# This file contains all the main external libs we'll use\n",
"from fastai.imports import *"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
"from fastai.transforms import *\n",
"from fastai.conv_learner import *\n",
"from fastai.model import *\n",
"from fastai.dataset import *\n",
"from fastai.sgdr import *\n",
"from fastai.plots import *"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Loading Data"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [],
"source": [
"folder_path = \"/workspace/datasets/cifar-10/\"\n",
"label_csv = os.path.join(folder_path, \"trainLabels.csv\")\n",
"sz = 32\n",
"bs=32"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [],
"source": [
"classes = ('plane', 'car', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck')\n",
"stats = np.array([0.5, 0.5, 0.5]), np.array([0.5, 0.5, 0.5])"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"def get_data_from_csv(stats, sz, bs, folder_path, label_csv, tfms, skip_header=True, suffix=\".jpg\",\n",
" train_folder=\"train\", test_folder=None, val_pct=0.2,\n",
" num_workers=8):\n",
"\n",
" n = len(list(open(label_csv)))\n",
" if skip_header:\n",
" n -= 1\n",
" val_idxs = get_cv_idxs(n, val_pct=val_pct)\n",
"\n",
" return ImageClassifierData.from_csv(folder_path, \n",
" train_folder, \n",
" label_csv, \n",
" tfms=tfms,\n",
" skip_header=skip_header,\n",
" suffix=suffix, \n",
" val_idxs=val_idxs, \n",
" test_name=test_folder,\n",
" bs=bs,\n",
" num_workers=num_workers)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"aug_tfms = [RandomFlipXY()]\n",
"tfms = tfms_from_stats(stats, sz, aug_tfms=aug_tfms, max_zoom=1.05, pad=0, crop_type=CropType.NO, tfm_y=None)\n",
"\n",
"dataset = get_data_from_csv(stats, sz, bs, folder_path, label_csv, tfms, suffix=\".png\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Instantiate the Model and Learner"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"class Cifar10Net(nn.Module):\n",
" \"\"\"Basic Custom Conv Net\n",
" \"\"\"\n",
" def __init__(self, *args, **kwargs):\n",
"\n",
" super().__init__(*args, **kwargs)\n",
"\n",
" # 3 x 32 x 32 -> 64 x 32 x 32\n",
" self.conv1 = nn.Conv2d(3, 64, 3, padding=1)\n",
" # 64 x 32 x 32 -> 128 x 16 x 16\n",
" self.conv2 = nn.Sequential(\n",
" nn.Conv2d(64, 128, 3, padding=1), \n",
" nn.MaxPool2d(2)\n",
" )\n",
" # 128 x 16 x 16 -> 256 x 8 x 8\n",
" self.conv3 = nn.Sequential(\n",
" nn.Conv2d(128, 256, 3, padding=1),\n",
" nn.MaxPool2d(2)\n",
" )\n",
" # 256 x 8 x 8 -> 10 x 8 x 8\n",
" self.conv_out = nn.Conv2d(256, 10, 3, padding=1)\n",
" \n",
" def forward(self, x):\n",
" \n",
" x = F.relu(self.conv1(x)) # Relu on Conv\n",
" x = F.relu(self.conv2(x))\n",
" x = F.relu(self.conv3(x))\n",
" x = F.relu(self.conv_out(x))\n",
" x = F.avg_pool2d(x, 8) # Global Average pooling on 10 x 8 x 8\n",
" x = x.view(x.size(0), -1)\n",
" return F.log_softmax(x)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"m = Cifar10Net()\n",
"cifar_model = BasicModel(to_gpu(m), name='cifar10')"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"learn = ConvLearner(dataset, cifar_model)\n",
"learn.unfreeze()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### LR Finder"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4d7246497a514b22a34fa7bd3ae5c9aa",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"A Jupyter Widget"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[ 0. 2.30271 2.30259 0.10154] \n",
"\n"
]
}
],
"source": [
"learn.lr_find()"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYwAAAEOCAYAAACaQSCZAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAIABJREFUeJzt3Xl8XNV58PHfMzMa7ZK1eZN3bGMD\nBts4xMSsISELNGShCWlCQkJC6JsESElKljZNk74pfdvSrEAoJCUtSwMYwhbCEiAQVtt4ww7GNjaW\nLduSrH2b7Xn/uFfyWJbkkT1Xd5bn+/nMR3fuPXfmObrSPHPuufccUVWMMcaYIwn4HYAxxpjsYAnD\nGGNMSixhGGOMSYklDGOMMSmxhGGMMSYlljCMMcakxBKGMcaYlFjCMMYYkxJLGMYYY1JiCcMYY0xK\nQn4HkE61tbU6a9Ysv8MwxpissXr16mZV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4PQRPO8uv4Rzyomk7YcQkalA\nj6r+D04LZCnwZ2CqiLzDLVPuduJX4rQ8EsClOHNFD/V74K9FpMDdd77bMgGnRTLq1VQmu1nCML5T\n1cdxTqm8KCIbgHtxPnAfA0Iish74Ac4HpBfuwxkqeiPwC+BloD2F/b4H3CMizwHNSesfAj4y0OkN\nXAUsczuJNzHMLGiq+meg0u38Huoq4HPu7+FS4Gp3/TXA34jIKzintIaLeRHwioisBb4D/JOqRoBP\nAD8VkXXAEzitgxuBz4rISzgf/t3DvN6tOHNFr3Evtf0FB1tz5wKPDLOPyRE2vLkxgIiUqWqXiNQA\nrwArVHXvOMfwNaBTVW9NsXwJ0KuqKiKX4HSAX+RpkKPH80fgIlVt9SsG4y3rwzDG8bCITMDpvP7B\neCcL103AX46h/Kk4ndQCtOFcQeULEanD6c+xZJHDrIVhjDEmJdaHYYwxJiWWMIwxxqTEEoYxxpiU\nWMIwxhiTEksYxhhjUmIJwxhjTEr+P0HXYH01Wbi5AAAAAElFTkSuQmCC\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x7f86970605c0>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"learn.sched.plot()"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"# Set the Learning Rate\n",
"lr=1e-2"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "8ac0e33439534f838703bf1a53e7be2f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"A Jupyter Widget"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[ 0. 1.62316 1.59802 0.40665] \n",
"\n",
"CPU times: user 41.1 s, sys: 27.4 s, total: 1min 8s\n",
"Wall time: 1min 7s\n"
]
}
],
"source": [
"%time learn.fit(lr, 1)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "1f0fc15c1dd24106982dac057cd171c3",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"A Jupyter Widget"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[ 0. 1.35955 1.34674 0.52626] \n",
"[ 1. 1.3159 1.25054 0.55691] \n",
"[ 2. 1.17125 1.15738 0.59525] \n",
"[ 3. 1.18631 1.18037 0.58826] \n",
"[ 4. 1.08554 1.12625 0.59774] \n",
"[ 5. 0.96763 0.96539 0.66494] \n",
"[ 6. 0.91771 0.93701 0.67722] \n",
"\n"
]
}
],
"source": [
"learn.fit(lr, 3, cycle_len=1, cycle_mult=2)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment