Jupyter Notebooks
Last updated
Last updated
Jupyter Notebook is an open-source application, popular in the machine learning community, that allows you to create and share documents comprised of live code (e.g., Python code), equations, and other types of content. Each block of content is displayed in a box called a "cell". Within PerceptiLabs you can view this in the code view.
Each component that you add to your PerceptiLabs model contains Python code that you can view and modify. PerceptiLabs' Notebook view, accessible by toggling the Notebook button (1) on the Modeling Tooltab (2), allows you to view and share all of that code as a Jupyter Notebook (.ipynb file):
There is one class per component in a PerceptiLabs model, and each class is displayed in a code cell (3) within the notebook.
A Jupyter Notebook file is a JSON file with a .ipynb
file extension, that contains the content and all of the metadata required to display that content in Jupyter Notebook cells. When you export your model from PerceptiLabs, the exported file will contain the following cells:
A basic code cell defining the imports and logger. For example:
The logger is included to handle log messages and convey information during initialization and training. It streams the logs to "stdout", which in most cases is the terminal where you run the code from. When running online, this may log to a file or may stream messages to an online viewer, depending on the setup.
One cell for each component in your model containing the component's class. For example, the following shows some of the code from a Reshape component:
One final cell defining the model's layers, edges (connections between the layers), and a GraphBuilder to run the model. For example, the following shows these elements for a simple image classification model:
You can export your code to a Jupyter Notebook file as described here.
You can run the Jupyter Notebook file that you exported from PerceptiLabs, in either an online or local Jupyter Notebook environment. Before you can do so, you must first install PerceptiLabs in that environment using:
pip install perceptilabs
Once installed, you can then open the exported .ipnyb file in Jupyter notebook and run the notebook's various code cells.
When executing the model in Jupyter Notebook, run the initialization cell first, then all the component cells (order does not matter) and finally the last cell. See the previous section for information about each cell.