Log fast.ai metrics to neptune

fastai neptune.ml integration

Prerequisites

Create your databunch.

[ ]:
from fastai.vision import *
path = untar_data(URLs.MNIST_TINY)

data = ImageDataBunch.from_folder(path, ds_tfms=(rand_pad(2, 28), []), bs=64)
data.normalize(imagenet_stats)

Create the learner find your optimal learning rate and plot it

[ ]:
learn = cnn_learner(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')

path = untar_data(URLs.MNIST_TINY)

data = ImageDataBunch.from_folder(path, ds_tfms=(rand_pad(2, 28), []), bs=64)
data.normalize(imagenet_stats)

learn = cnn_learner(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)