Skip to content

Instantly share code, notes, and snippets.

@borisdayma
Last active April 13, 2020 18:45
Show Gist options
  • Save borisdayma/aebd3219b64ee01a380c42ff3a96ba3d to your computer and use it in GitHub Desktop.
Save borisdayma/aebd3219b64ee01a380c42ff3a96ba3d to your computer and use it in GitHub Desktop.
Demo WandbCallback for fastai2
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from fastai2.vision.all import *\n",
"\n",
"import wandb\n",
"from fastai2.callback.wandb import *"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"path = untar_data(URLs.MNIST_TINY)\n",
"items = get_image_files(path)\n",
"tds = Datasets(items, [PILImageBW.create, [parent_label, Categorize()]], splits=GrandparentSplitter()(items))\n",
"dls = tds.dataloaders(after_item=[ToTensor(), IntToFloatTensor()])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wandb.init(project='test')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"learn = cnn_learner(dls, resnet34, loss_func=CrossEntropyLossFlat(), cbs=WandbCallback())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"learn.fit(3, lr=0.01)"
]
}
],
"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