Callbacks that saves the tracked metrics during training and output logs for tensorboard to read
Tensorboard¶
Load tensorboard magic command to show tensorboard embed in Jupyter Notebook.
%load_ext tensorboard
First let's show an example of use, with a training on the MovieLens sample dataset.
path = untar_data(URLs.ML_SAMPLE)
ratings = pd.read_csv(path/'ratings.csv')
series2cat(ratings, 'userId', 'movieId')
data = CollabDataBunch.from_df(ratings, seed=42)
learn = collab_learner(data, n_factors=30, y_range = [0, 5.5])
Specify log path for tensorboard to read from. Then append callback partial to learner callback functions.
project_id = 'projct1'
tboard_path = Path('data/tensorboard/' + project_id)
learn.callback_fns.append(partial(LearnerTensorboardWriter,
base_dir=tboard_path,
name='run1'))
run tensorboard magic command with logdir parameter. Default port is 6006.
%tensorboard --logdir=$tboard_path --port=6006
Or you can launch the Tensorboard server from shell with tensorboard --logdir=data/tensorboard/project1 --port=6006
then navigate to http://localhost:6006
learn.fit(10)
Calback methods¶
You don't call these yourself - they're called by fastai's Callback
system automatically to enable the class's functionality.