Log fast.ai metrics to neptune

fastai neptune.ml integration

Prerequisites

Create your databunch.

[ ]:
from fastai.vision import *
mnist = untar_data(URLs.MNIST_TINY)
tfms = get_transforms(do_flip=False)
data = (ImageItemList.from_folder(mnist)
    .split_by_folder()
    .label_from_folder()
    .transform(tfms, size=32)
    .databunch()
    .normalize(imagenet_stats))

Create the learner find your optimal learning rate and plot it

[ ]:
learn = create_cnn(data, models.resnet18, metrics=accuracy)
learn.lr_find()
learn.recorder.plot()

image1

Create an experiment and add neptune_monitor callback

[ ]:
import neptune
from neptunecontrib.monitoring.fastai import NeptuneMonitor

neptune.init(project_qualified_name='USER_NAME/PROJECT_NAME')

with neptune.create_experiment(params={'lr': 1e-2}):
    learn.callbacks.append(NeptuneMonitor())
    learn.fit_one_cycle(20, 1e-2)

Monitor your fast.ai training in neptune

Now you can watch your fast.ai model training in neptune!

Go to the experiment link to see for yourself.

image2

Full fast.ai monitor script

[ ]:
from fastai.vision import *
import neptune
from neptunecontrib.monitoring.fastai import NeptuneMonitor

neptune.init(project_qualified_name='USER_NAME/PROJECT_NAME')

mnist = untar_data(URLs.MNIST_TINY)
tfms = get_transforms(do_flip=False)

data = (ImageItemList.from_folder(mnist)
        .split_by_folder()
        .label_from_folder()
        .transform(tfms, size=32)
        .databunch()
        .normalize(imagenet_stats))

learn = create_cnn(data, models.resnet18, metrics=accuracy)
learn.lr_find()
learn.recorder.plot()

with neptune.create_experiment(params={'lr': 1e-2}):
    learn.callbacks.append(NeptuneMonitor())
    learn.fit_one_cycle(20, 1e-2)