Neptune-fastai Integration

The integration enables you to log fast.ai metrics to Neptune.

fast.ai neptune.ai integration

Requirements

Integration with the fastai framework is enabled as a part of neptune-contrib, an open source project curated by the Neptune team.

Install fast.ai before you continue. For more information, check the docs.

pip install neptune-contrib
pip install neptune-contrib[monitoring]

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()
learning rate finder plot

Create an experiment and add the 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 = cnn_learner(data, models.resnet18, metrics=accuracy,
                        callback_fns=[NeptuneMonitor])
    learn.fit_one_cycle(20, 1e-2)

Monitor your fastai training in Neptune

Now you can watch your fastai model training in Neptune!

charts for the example fast.ai experiment

Full fastai monitor script

Simply copy and paste it to fastai_example.py and run.

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 = cnn_learner(data, models.resnet18, metrics=accuracy,
                        callback_fns=[NeptuneMonitor])
    learn.fit_one_cycle(20, 1e-2)