Add records to Experiment Recorder

Recording experiment data through the experiment recorder during the model training.

You will learn to record experiment data using the experiment recorder during model training. But first, make sure to create an experiment recorder. If you haven't already, refer to the Create Experiment Recorder page.

An ExperimentRecorder has the following key methods:

  • start(): This method initiates the model training process and should be called just before the training code begins executing.
  • stop(): Once the model training is completed, stop() method is used to conclude the training process. It should be called immediately after the training code finishes.
  • add_record({"key": value}): This API is used to record metrics within MarkovML. You can assign any string as a key and a corresponding numeric value. During the training loop, you will call this method to record metrics such as loss and accuracy. These recorded metrics will then be visualized as charts in the MarkovML UI.

πŸ“˜

Add-on Info

The recorder instance can also be utilized as a context manager using the with statement to avoid explicit calls to the start() and stop() methods.

Complete Sample Code to add records to the Experiment Tracking Recorder.

import markov

# Your model definition 
# model = ...

# create recorder
recorder = markov.ExperimentRecorder(
	name="MarkovML Experiment #1"
)
# The register method registers this recorder with the MarkovML backend. 
# You can record data with the backend only through a registered recorder.
recorder.register()

with recorder:
    for epoch in range(500):
        pred = model(x)  
        # Calculate and record loss
        loss = loss_function(pred, y)
        recorder.add_record({"loss": loss})
        
        # calculate and record accuracy
        accuracy = accuracy_function(pred, y)
        recorder.add_record({"accuracy": accuracy})
        
        # REST OF THE MODEL TRAINING CODE GOES HERE

πŸ“˜

Integrations with ML Frameworks

Markov has easy integrations with many popular machine-learning frameworks. Please refer to Integrations page.