Created
April 13, 2020 21:34
-
-
Save borisdayma/0ffa2550dbf45010623f29eb15c3b1e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from fastai.vision import *\n", | |
"import wandb\n", | |
"from wandb.fastai import WandbCallback" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"MNIST_PATH = str(untar_data(URLs.MNIST_TINY))\n", | |
"path = untar_data(MNIST_PATH)\n", | |
"data = ImageDataBunch.from_folder(path, size=90)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"\n", | |
" Logging results to <a href=\"https://wandb.com\" target=\"_blank\">Weights & Biases</a> <a href=\"https://docs.wandb.com/integrations/jupyter.html\" target=\"_blank\">(Documentation)</a>.<br/>\n", | |
" Project page: <a href=\"https://app.wandb.ai/borisd13/uncategorized\" target=\"_blank\">https://app.wandb.ai/borisd13/uncategorized</a><br/>\n", | |
" Run page: <a href=\"https://app.wandb.ai/borisd13/uncategorized/runs/3rxfppp1\" target=\"_blank\">https://app.wandb.ai/borisd13/uncategorized/runs/3rxfppp1</a><br/>\n", | |
" " | |
], | |
"text/plain": [ | |
"<IPython.core.display.HTML object>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"W&B Run: https://app.wandb.ai/borisd13/uncategorized/runs/3rxfppp1" | |
] | |
}, | |
"execution_count": 3, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"wandb.init()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"learn = cnn_learner(data, models.resnet18, metrics=accuracy, callback_fns=WandbCallback)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: left;\">\n", | |
" <th>epoch</th>\n", | |
" <th>train_loss</th>\n", | |
" <th>valid_loss</th>\n", | |
" <th>accuracy</th>\n", | |
" <th>time</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <td>0</td>\n", | |
" <td>0.278620</td>\n", | |
" <td>0.644932</td>\n", | |
" <td>0.693848</td>\n", | |
" <td>00:01</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>1</td>\n", | |
" <td>0.161620</td>\n", | |
" <td>1.431106</td>\n", | |
" <td>0.532189</td>\n", | |
" <td>00:00</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>2</td>\n", | |
" <td>0.114893</td>\n", | |
" <td>1.007536</td>\n", | |
" <td>0.619456</td>\n", | |
" <td>00:00</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>" | |
], | |
"text/plain": [ | |
"<IPython.core.display.HTML object>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Better model found at epoch 0 with valid_loss value: 0.6449324488639832.\n", | |
"Loaded best saved model from /home/boris/Projects/fastai_bug/wandb/run-20200413_213315-3rxfppp1/bestmodel.pth\n" | |
] | |
} | |
], | |
"source": [ | |
"learn.fit(3)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"learn.export('learner.pkl')" | |
] | |
} | |
], | |
"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.8.1" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment