How PerceptiLabs Works With TensorFlow

PerceptiLabs is built on top of TensorFlow and Keras, and provides a visually-intuitive user interface (UI) that assists you with building TensorFlow-based machine learning models. This topic provides existing TensorFlow users with details on how PerceptiLabs uses TensorFlow, and the correlation between visual modeling and the underlying TensorFlow code.

Note: Early versions of PerceptiLabs up through v0.11.11 used TensorFlow 1.x. As of v0.11.13, PerceptiLabs uses TensorFlow 2.x. When loading models from previous versions of PerceptiLabs, be sure to review your model’s Components, as some may not be compatible with v0.11.13+. See our change log more additional information.

Layers as Components

Since models are built visually in PerceptiLabs, the layers of a model are represented using Deep Learning Components in PerceptiLabs' Modeling Tool. You can also optionally add Processing, Operations, and Custom Components to transform data between these layers. The model's Input and Target components are hard-coded into the model by PerceptiLabs to define the input data and output predictions respectively.

Fundamentals of Components

Each Component in your model represents an auto-generated class written in Python, which implements that Component's logic with TensorFlow. You can view and edit a Component's code via its code editor as described in Modifying a Component's Code.

Class Naming Convention

The name of a Component's auto-generated class encodes the Component's category, Component type, and an instance name appended with the instance number. The instance number corresponds to when the component was added to the model in relation to other components of the same type. For example, the following is a code snippet from a Reshape Component in a model:

class ProcessReshape_Reshape_2Keras(tf.keras.layers.Layer):
...

The class name can be broken down as follows:

  • Process: the name of the Component category that the Component was dragged onto the model from.

  • Reshape: the type of the Component.

  • Reshape_2: the name of the Component instance. In this example, 2 means it was the second reshape Component instance added to the model.

  • Keras: indicates that this implementation is based on Keras.

Elements of the Component Class's Interface

Each Component's class derives from a PerceptiLabs-defined parent class, that defines the interface required for PerceptiLabs' training script to invoke operations and pass results onto subsequent Components. PerceptiLabs will regenerate this class when changes are made in the Component's Settings screen (i.e., changes to hyperparameters). The following are common interface elements found in many classes.

A "Layer" Component implements tf.keras.layers.Layer that defines an interface (i.e., the functions and properties) for the layer with the following:

  • visualized_trainable(): returns the layer's weights and biases to be updated during training.

  • __init__(): the class's constructor.

  • call(): invoked by PerceptiLabs when you run the model. This is likely to be the only method that you would modify if you're customizing the class's algorithm.

  • build(): creates the layer's weights based on its shape.

  • get_config(): returns any properties that are to be accessible in PerceptiLabs' UI.