Notebook Examples Guide

The MLTK Tutorials and API Examples are implemented in a Jupyter Notebooks. A Notebook allows for Markdown documentation with inline, executable Python code.

This describes how to run the a Notebook locally in VSCode or remotely on Google Colab

VSCode Notebooks

VSCode allows for running Notebooks locally on your PC.
Refer to the official VS Code Notebook documentation for getting started.

To run an MLTK example or tutorial notebook in VSCode:

  1. Open VSCode

  2. Select a Python Interpreter
    This can be any supported Python Interpreter (Python 3.9, 3.10, 3.11, or 3.12), however, it’s recommended to create a Python “virtual environment” for installing the MLTK.
    See the Installation Guide for more details.
    To select the Python Interpreter open the VSCode “Command Palette” (Ctrl+Shift+P), and enter: Python: Select Interpreter
    Then find/enter the path to the Python executable you want to use.

    Select Python Interpreter

  3. Open an MLTK example or tutorial (file extension .ipynb) in VSCode

  4. Press the Select Kernel button on the upper-right and select the Python Interpreter from step 2

    Select Kernel

  5. Run an executable cell in the Notebook
    The first time you run a cell, you may be prompted to Install ipykernel Click “Install” to install the package.
    You should now be able to fully execute the examples and tutorials from the VSCode notebook environment

    Install Ipykernel

Google Colab

Google Colab is a free service provided by Google that allows for leveraging the Google cloud servers and GPUs for training your model.

NOTE: When running on Colab, the MLTK executes on the remote Google servers. As such, some commands that require local access are not supported.

To run an MLTK example or tutorial in Colab:

  1. Create a Google Account (if necessary)
    Go to the Google Signup page.
    NOTE: Click the Use my current email address instead button to use your existing email instead of creating a gmail email address.

  2. Select the example or tutorial you want to run, and click the Open In Colab button at the top of the example or tutorial

  3. At this point, you should be able to execute the example or tutorial on Colab
    NOTE: Be sure to first install the MLTK via pip !pip install silabs-mltk, all the examples/tutorials have this code at the top

NOTE: When training a model a Google Colab, be sure to first select the GPU hardware accelerator:

GPU Accelerator