2020-12-22 21:25:37 +00:00
|
|
|
# ClearML - Fastai with Tensorboard example code, automatic logging the model and Tensorboard outputs
|
2020-08-10 05:01:03 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
from fastai.callbacks.tensorboard import LearnerTensorboardWriter
|
|
|
|
from fastai.vision import * # Quick access to computer vision functionality
|
|
|
|
|
2020-12-22 21:25:37 +00:00
|
|
|
from clearml import Task
|
2020-08-10 05:01:03 +00:00
|
|
|
|
2020-12-23 22:30:32 +00:00
|
|
|
# Connecting ClearML with the current process,
|
|
|
|
# from here on everything is logged automatically
|
2022-02-14 08:18:41 +00:00
|
|
|
task = Task.init(project_name="examples", task_name="Fastai with TensorBoard callback")
|
2020-08-10 05:01:03 +00:00
|
|
|
|
|
|
|
path = untar_data(URLs.MNIST_SAMPLE)
|
|
|
|
|
|
|
|
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)
|
|
|
|
tboard_path = Path("data/tensorboard/project1")
|
|
|
|
learn.callback_fns.append(
|
|
|
|
partial(LearnerTensorboardWriter, base_dir=tboard_path, name="run0")
|
|
|
|
)
|
|
|
|
|
|
|
|
accuracy(*learn.get_preds())
|
|
|
|
learn.fit_one_cycle(6, 0.01)
|