Skip to content

Class Mappings for PyTorch

This topic shows you how to set class mappings and their effects. The topic builds on Getting Started for PyTorch with steps.

The following steps are covered:

  • Create a class mapping for MNIST.
  • Set the class mapping to MissingLink's callback.

Preparation

Go through Getting Started for PyTorch.

Note

Ensure that you can successfully run the mnist.py training script that resulted from integration with the MissingLink SDK. In the steps that follow below, the script is further developed to include class mappings.

Write code

  1. Create a class mapping for MNIST.

    Above the call to create_experiment, add a mnist class mapping:

    mnist_class_mapping = {
        0: 'zero',
        1: 'one',
        2: 'two',
        3: 'three',
        4: 'four',
        5: 'five',
        6: 'six',
        7: 'seven',
        8: 'eight',
        9: 'nine',
    }
    
    with missinglink_project.create_experiment(
        model,
        metrics={'loss': loss},
        display_name='MNIST multilayer perception',
        description='Two fully connected hidden layers') as experiment:
    
  2. Set the class mapping to the callback.

    Modify the original set properties to the following:

    with missinglink_project.create_experiment(
        model,
        metrics={'loss': loss},
        display_name='MNIST multilayer perception',
        description='Two fully connected hidden layers',
        class_mapping=mnist_class_mapping) as experiment:
    

You should have added class mappings to your experiment successfully.

  • Inspect the resulting script here.
  • Run the new script and see how MissingLink's dashboard helps with monitoring the experiment's class mappings.