Training
A complete training script: it reads a dataset, trains in stages, keeps a figure per epoch, and saves the model.
Setup
pip install "hectiqlab[cli]"
hlab login
hlab init hectiq-ai/demoThe script
import hectiqlab as hl
@hl.stage
def prepare(folder):
... # load the data and build the model
return loader, model
def main():
folder = hl.datasets.download("interactions").result()
loader, model = prepare(folder)
with hl.stage("train"):
for epoch in hl.each(range(10), "epoch"):
for batch in hl.each(loader):
loss = model.step(batch)
hl.add_metric("loss", step=epoch, value=loss)
figure = plot_confusion(model)
figure.savefig("confusion.png")
hl.artifacts.create("confusion.png", group="confusion", step=epoch)
model.save("checkpoints/")
hl.models.create("checkpoints/", name="two-tower")
with hl.run("Two-tower, 10 epochs", category="training", tags=["ENG-42"], config={"lr": 1e-3}):
main()In the web app, the run shows the stages prepare, then train with epoch-0 to epoch-9 inside it, each with a bar for its batches. It lists the dataset it read, which download records, the model it made, the loss, and the confusion figure of every epoch.