-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Currently, we are modifying an existing DLSIA function train_segmentation to write/export the loss and metrics at every epoch while the training process is ongoing.
We (@xiaoyachong @zhuowenzhao @taxe10) discussed about how to integrate DVC without modifying the DLSIA function at our end. Here we summarize our initial thoughts:
In MLExchange:
# train.py
from dvclive import Live
from dlsia.core import train_segmentation
# Creates custom exporter class compatible with DVC
class DvcExporter:
def __init__(self, live):
self.live = live
def export_train_metrics(self, metrics):
# DVC code
# Init DVC Live
with Live() as live:
# Define the parameters to be tracked
live.log_param("epochs", NUM_EPOCHS)
# Init custom exporter
dvc_exporter = DvcExporter(live)
# Calls DLSIA function with custom exporter
train_segmentation(net, trainloader, validationloader, NUM_EPOCHS,
criterion, optimizer, device,
savepath=None, saveevery=None,
scheduler=None, show=0,
use_amp=False, clip_value=None, custom_exporter=dvc_exporter)
live.log_artifact(path, type="model", name=name)
This would require a PR in DLSIA that would look as follows:
def train_segmentation(net, trainloader, validationloader, NUM_EPOCHS,
criterion, optimizer, device,
savepath=None, saveevery=None,
scheduler=None, show=0,
use_amp=False, clip_value=None, custom_exporter=None):
.........
for epoch in range(NUM_EPOCHS):
....
## After validation maybe around https://github.com/phzwart/dlsia/blob/f3f50a78faeb99aca4b9725ffa63c7b95c0613df/dlsia/core/train_scripts.py#L228
if custom_exporter is not None:
custom_exporter.export_train_metrics(metrics)
This is a very rough draft, mostly to gather feedback.
Any thoughts and/or comments? @Wiebke @dylanmcreynolds @TibbersHao
Metadata
Metadata
Assignees
Labels
No labels