# Create a mapping (Deprecated)

{% hint style="success" %}
In order to create a mapping a model and code integration should previously been integrated into Tensorleap.&#x20;
{% endhint %}

In order to create a mapping in the Tensorleap platform a user can add several UI blocks to its' model representation in the Network view.

This is usually done either in the first time a new architecture was uploaded to Tensorleap or when a new Metric, Loss, or Visualizer was added via the [Integration Script](https://docs.tensorleap.ai/tensorleap-integration/writing-integration-code).&#x20;

<figure><img src="https://3509361326-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9UXeOlFqlw8pl79U2HGU%2Fuploads%2FypfQCMJ0E3UdVHrRBRqX%2Fnew_mapping.gif?alt=media&#x26;token=7fef339b-27d3-40fe-910b-09c668df487f" alt=""><figcaption><p>An example mapping creation process</p></figcaption></figure>

## When should a mapping be created or updated

### The First Time a new architecture is uploaded

Once a new architecture has been successfully uploaded to Tensorleap, we would like to create a new mapping to instruct the platform on how to visualize elements, and what should be the inputs to the loss and metrics.&#x20;

In order to create a mapping for the first time, you can use the [Network Wizard](https://docs.tensorleap.ai/user-interface/project/network/network-mapping/create-a-mapping-deprecated/network-wizard) . It would give step-by-step instructions on how to create a valid mapping for your model.

### A new loss, metric, or visualizer was added to the Integration

In case you already have a mapping, but you've added a new  [visualizer](https://docs.tensorleap.ai/user-interface/project/network/network-mapping/create-a-mapping-deprecated/visualizer-node), [metric](https://docs.tensorleap.ai/user-interface/project/network/network-mapping/create-a-mapping-deprecated/metric-node), or [loss](https://docs.tensorleap.ai/user-interface/project/network/network-mapping/create-a-mapping-deprecated/loss-node) to your [Integration script](https://docs.tensorleap.ai/tensorleap-integration/writing-integration-code) that you would like to use, you would need to change your mapping to instruct the platform on how to use this element.

You can than simply add the corresponding element to the UI, [save the changes ](https://docs.tensorleap.ai/user-interface/project/network/..#the-controller)to your model, [validate](https://docs.tensorleap.ai/user-interface/project/network/network-mapping/validate-mapping), and [save](https://docs.tensorleap.ai/user-interface/project/network/network-mapping/save-mapping-to-file-deprecated) it for future use.

## How to change the Network mapping

### Adding Nodes

{% hint style="info" %}
Before changing an existing mapping, ensure the correct [code integration](https://docs.tensorleap.ai/user-interface/project/network/code-integration) script and version is selected from the right hand controller. This would allow you to add specific elements to the mapping that was defined in that script.
{% endhint %}

The Tensorleap mapping can be changed by adding or modifying existing nodes in the UI.

To add a new element, simply right click anywhere in the Network view, choose the element you want, and connect it to the corresponding source. Connections are performed by a drag-and-drop operation - dragging from the output of one node into the input of another.

<figure><img src="https://3509361326-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9UXeOlFqlw8pl79U2HGU%2Fuploads%2FEqhXdj4OsYMnb7W6F3ea%2Fimage.png?alt=media&#x26;token=e3d85947-6602-4197-947d-1fd3dce8721c" alt=""><figcaption><p>Right Clicking anywhere allows to add UI nodes</p></figcaption></figure>

The elements you can add are a collection of default visualizers, loss, metrics in addition to custom one that you've defined in your [integration script](https://docs.tensorleap.ai/tensorleap-integration/writing-integration-code):

* [Input Node](https://docs.tensorleap.ai/user-interface/project/network/network-mapping/create-a-mapping-deprecated/input-node) - connects the [**Input Encoders**](https://docs.tensorleap.ai/tensorleap-integration/writing-integration-code/input-encoder) created in the script with your model
* [Ground Truth](https://docs.tensorleap.ai/user-interface/project/network/network-mapping/create-a-mapping-deprecated/ground-truth-node) - connects the [**Ground Truth encoder**](https://docs.tensorleap.ai/tensorleap-integration/writing-integration-code/ground-truth-encoder) created in the script with your model
* [Custom Loss](https://docs.tensorleap.ai/user-interface/project/network/network-mapping/create-a-mapping-deprecated/loss-node) - connects a [**Custom Loss**](https://docs.tensorleap.ai/tensorleap-integration/writing-integration-code/custom-loss-function) created in the script with your model
* [Loss](https://docs.tensorleap.ai/user-interface/project/network/network-mapping/create-a-mapping-deprecated/loss-node) - connect a default losses to your model
* [Visualizer](https://docs.tensorleap.ai/user-interface/project/network/network-mapping/create-a-mapping-deprecated/visualizer-node) - connects a default visualizer or a [**Custom Visualizer**](https://docs.tensorleap.ai/tensorleap-integration/writing-integration-code/visualizer-function) created in the script with your model.
* [Metric](https://docs.tensorleap.ai/user-interface/project/network/network-mapping/create-a-mapping-deprecated/metric-node) - connects a default metric or a [**Custom Metric**](https://docs.tensorleap.ai/tensorleap-integration/writing-integration-code/custom-metrics) created in the script with your model.

### Modifying Nodes

Each one of these nodes has some attributes that can be edited from the Node Details tab (right hand side). For example, if your model has multiple inputs you can select the input node by clicking on it, and a window would open that allows you to select the input you would like to use.

<figure><img src="https://3509361326-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9UXeOlFqlw8pl79U2HGU%2Fuploads%2FWg4ucapdjvdPWDyR2JHu%2Fimage.png?alt=media&#x26;token=06fd82a5-8eb5-420b-a4f0-339db80e7e7a" alt=""><figcaption><p>An input is selected by clicking on it. The panel that opens up allows to edit node specific properties</p></figcaption></figure>

### Deleting nodes

To delete nodes from the UI, right click any node. This would open a pop-up window with the trash can icon. Clicking it would remove the node from the mapping.

<figure><img src="https://3509361326-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9UXeOlFqlw8pl79U2HGU%2Fuploads%2FiItyGgQ1sSSvhEmtzr4r%2Fimage.png?alt=media&#x26;token=a2db270e-6c98-49b1-990b-5842db03b951" alt=""><figcaption><p>Right clicking a node removes a node from the graph</p></figcaption></figure>

{% hint style="warning" %}
Once nodes are added, modified, or deleted from the mapping it is important to use the <img src="https://3509361326-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9UXeOlFqlw8pl79U2HGU%2Fuploads%2FWg0YldWFnkRHqr2QQyu2%2Fimage.png?alt=media&#x26;token=8d256e42-8c13-45c3-870f-81877c2347d2" alt="" data-size="line">  button to save your changes to the mapping graph. Any unsaved changes in the configuration would be indicated by an orange dot over the save icon <img src="https://3509361326-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9UXeOlFqlw8pl79U2HGU%2Fuploads%2Fe8LagrV4wzNS2o9vOxSE%2Fimage.png?alt=media&#x26;token=3a8521ae-9e04-4207-987b-51c58b2fdc9f" alt="" data-size="line">.&#x20;
{% endhint %}

{% hint style="info" %}
After you are satisfied with the changes in your mapping you should [validate](https://docs.tensorleap.ai/user-interface/project/network/network-mapping/validate-mapping) it is correct, and then [save it to file](https://docs.tensorleap.ai/user-interface/project/network/network-mapping/save-mapping-to-file-deprecated) so you'll be able to [re-apply](https://docs.tensorleap.ai/user-interface/project/network/network-mapping/applying-a-mapping-deprecated) it at will.
{% endhint %}
