# Validate mapping

{% hint style="success" %}
It is highly recommended to utilize the [integration test](https://docs.tensorleap.ai/tensorleap-integration/integration-test) locally before validating your assets in the platform. This allows you to ensure a smooth code flow, and to fix any issues within your local debugging environment
{% endhint %}

### When should assets be validated?

Assets in the platform should be validated after

* A new mapping was [created or modified ](https://docs.tensorleap.ai/user-interface/project/network/network-mapping/create-a-mapping-deprecated)in the platform
* Changes was made to the linked [code integration](https://docs.tensorleap.ai/user-interface/project/network/code-integration) script causing data flow to change
* A new model was uploaded to the platform, with a different architecture than previous models

{% hint style="info" %}
If you're unsure whether the assets for this specific configuration was tested, check the color of the Validate Assets button in the [code integration](https://docs.tensorleap.ai/user-interface/project/network/code-integration) view of the Network.

If it's <mark style="color:blue;">blue</mark> - no validation was tested on this configuration yet

If it's <mark style="color:green;">green</mark> - the assets in this configuration are valid

If it's <mark style="color:red;">red</mark> - The assets currently used in the platform are not valid
{% endhint %}

### How to validate assets in the platform

<figure><img src="https://3509361326-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9UXeOlFqlw8pl79U2HGU%2Fuploads%2FLAP4xK1LTSmzfTHzo72H%2Fimage.png?alt=media&#x26;token=52266e7d-5ee3-4f7f-a792-1dbe7da17bfc" alt=""><figcaption><p>An example of a mapping created but not validated</p></figcaption></figure>

To validate assets in the platform, we go to the Network Tab, and ensure:

* (optional) A fully completed [Network Wizard](https://docs.tensorleap.ai/user-interface/project/network/network-mapping/create-a-mapping-deprecated/network-wizard) indication, with all green markings.&#x20;
* A green "Validate Assets" Button within the Code mapping tab in the right of the Network tab.

{% hint style="info" %}
The Network Wizard ensures you would have all the assets needed for a complete experience of the Tensorleap platform. Since some of the assets (metrics) are not mendatory for the analysis to begin, it does not have to be completed before validating the ,apping
{% endhint %}

## Validate Assets

The "validate assets" process in Tensorleap aims to ensure current mapping that exists in the network graph is valid.\
\
Upon a click on the "Validate Assets" button - Tensorleap starts a process that would use your integration script to load data, run it throught the model, and visualize the inputs. A successful execution of this process means that your model and data is fully integrated & configured in Tensorleap, and you can begin the [evaluation](https://docs.tensorleap.ai/user-interface/project/menu-bar/evaluate-a-model) process.\
\
The validate assets does the following:

* It loads the code you set up in the [code integration](https://docs.tensorleap.ai/user-interface/project/network/code-integration) tab
* It initializes your [PreProcessing Function](https://docs.tensorleap.ai/tensorleap-integration/writing-integration-code/preprocess-function)
* It runs the first sample from your dataset and:
  * Use the [Input Encoder](https://docs.tensorleap.ai/tensorleap-integration/writing-integration-code/input-encoder) to load the input
  * Use the [Ground Truth Encoder](https://docs.tensorleap.ai/tensorleap-integration/writing-integration-code/ground-truth-encoder) (if present) to load the ground truth
  * Use the [Metadata Encoders](https://docs.tensorleap.ai/tensorleap-integration/writing-integration-code/metadata-function) (if present) to load the metadata
* It then utilize the Network Mapping to:
  * Feed the input to your model and infer it
  * Run connected metrics, loss, and visualizers&#x20;

<figure><img src="https://3509361326-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9UXeOlFqlw8pl79U2HGU%2Fuploads%2FsYrma75OZgdOAe0jzrbd%2Fimage.png?alt=media&#x26;token=97c326b2-231a-428c-9919-1f532faae54b" alt=""><figcaption><p>A successful assets validation indication in the platform.</p></figcaption></figure>

Once the validate assets process is successfully finished it is recommended to [save it to file](https://docs.tensorleap.ai/user-interface/project/network/network-mapping/save-mapping-to-file-deprecated) to ensure a re-use upon repeating uploads of the same model.

{% hint style="danger" %}
Assets validation mostly fail due to these reasons:

* A bug or unexpected use of the [integration script](https://docs.tensorleap.ai/tensorleap-integration/writing-integration-code). Can be mostly prevented with [integration testing](https://docs.tensorleap.ai/tensorleap-integration/integration-test).
* Connecting an asset to the wrong input. It is important to notice that the [mapping](https://docs.tensorleap.ai/user-interface/project/network/network-mapping/create-a-mapping-deprecated) connection are as the integration script expect them to be.&#x20;
  {% endhint %}

{% hint style="warning" %}
A successful validate assets does not ensure the loss, metrics, or visualizers would behave as you might have expected, especially, for custom defined encoders. It only ensures the Tensorleap platform is able to propagate data through your model and into these functions and get a valid reponse. We highly recommend utilizing the [integration test](https://docs.tensorleap.ai/tensorleap-integration/integration-test) ensure your custom defined properties return the expected result.
{% endhint %}

{% hint style="info" %}
Upon dataset parse (i.e. uploading a codebase to the model) inputs, ground truth, and metadata are also being run by Tensorleap. The process of "Validate Assets" is to validate the rest of the assets, defined by your mapping: i.e. model inference validity, metrics, losses, and visualizers.
{% endhint %}
