Import Model
Learn how to import models into Tensorleap
Tensorleap supports importing models exported to various standard formats, including standard TensorFlow (SaveModel/H5/JSON) and PyTorch (ONNX).
Formats
JSON_TF2 - JSON format (TensorFlow 2)
The JSON format serializes the model layers, their properties and connectivity. It does not hold the state (weights) of the model.
Below is a code snippet for saving a TensorFlow model as a JSON file:
More info at https://www.tensorflow.org/api_docs/python/tf/keras/models/model_from_json.
H5_TF2 - H5 format (TensorFlow 2)
The h5
format serializes the model and model state (weights) as a single h5
file.
Below is a code snippet for loading an exported h5
file:
More info at https://www.tensorflow.org/tutorials/keras/save_and_load.
ONNX format (PyTorch)
The onnx
format is commonly used in PyTorch for serializing the model's layers and state (weights).
Below is a code snippet for exporting a model to an onnx
file in PyTorch:
More info at https://pytorch.org/docs/stable/onnx.html.
SavedModel_TF2 - SaveModel serialization (TensorFlow 2)
Uses the TensorFlow 2 SaveModel
to export a folder with files containing the serialized model layers and state.
Below is a code snippet to load the model from the extracted folder:
The serialized data is stored to a folder with this directory structure:
More info at https://www.tensorflow.org/api_docs/python/tf/keras/models/save_model.
When importing the folder generated by the model.save()
format from Tensorleap, the exported folder needs to be contained in a tar.gz
file.
One way to do it is by using tar
:
Import Model using UI
To import a model:
Enter the revision name and model name, and select the import file format from the list.
Click and select the import file from your system.
Optional: Select a Dataset to connect to your model
If your model contains Custom Layers this step is mandatory. You must first add these to the dataset script and select the dataset before moving to the next step.
5. Click Import.
6. Once the import process is complete, the model is added to the Versions view.
8. Back on the Network view, point the Dataset Block to the model's Dataset Instance and connect it to the first layer in the network.
Once a dataset has been integrated with Tensorleap, it becomes available for use with your models. More info about Dataset Integration can be found at Dataset.
8. Add a Loss and Optimizer for the network, then set it up for training.
Last updated