Load tensorboard magic command to show tensorboard embed in jupyter notebook.
Broadly useful callback for Learners that writes to Tensorboard. Writes model histograms, losses/metrics, and gradient stats.
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
You don't call these yourself - they're called by fastai's
Callback system automatically to enable the class's functionality.