-
Notifications
You must be signed in to change notification settings - Fork 3
Model Export
This function is the meat of nexport. It allows users to pass in a model compiled with either PyTorch or TensorFlow and export it to any supported file type.
import nexport
nexport.export(model=model,
filetype="json"
filename="model",
indent=4,
verbose=1,
include_metadata=True,
model_name="Example Model",
model_author="Jordan Welsman",
activation_function="sigmoid",
uses_skip_connections=False
)
Argument | Data type | Default | Description |
---|---|---|---|
model |
object | Instantiated PyTorch or TensorFlow model | |
filetype |
string | Intended export filetype extension | |
filename |
string | model |
Name to be used for output file, excluding extension |
indent |
integer | 4 |
Number of spaces to be used to indent JSON object |
verbose |
integer | 1 |
Degree of status output for model export |
include_metadata |
boolean | False |
Whether to include arguments as metadata header in output file |
model_name |
string | My Model |
Name of model to be used in metadata header |
model_author |
string | None |
Name of author of model to be used in metadata header |
activation_function |
string | None |
Activation function reference to be used in metadata header |
uses_skip_connections |
boolean | False |
Whether the model uses skip connections |
This is the number of spaces each line indentation should take up. This only applies to exporting to .json
, and .xml
. Other filetypes will ignore this parameter.
This is the degree of verbosity the function should output to when reporting the export status. There are currently four levels of verbosity:
-
0
: Status reporting disabled. No output to console when exporting. -
1
: Status reported when model has been successfully exported. -
2
: Status reported when parameters have been extracted from passes model, model object has been created, and export time reported, in addition to all updates in1
. -
3
: Status reported at start of layer creation and after each layer has been compiled, in addition to all updates in2
.
This is whether to include model_name
, model_author
, activation_function
, uses_skip_connections
and the compilation date in the header of the exported file:
-
True
: Tells the function to compile a metadata object and include it when writing the exported file. -
False
: Tells the function to discard any passed values formodel_name
andmodel_author
and to not compile a metadata object.
Argument | Required | Accepted values |
---|---|---|
model |
✅ | Any fully-connected PyTorch or TensorFlow model |
filetype |
✅ |
txt , json , csv , xml
|
filename |
❌ | Any string |
indent |
❌ | Any integer |
verbose |
❌ |
0 , 1 , 2 , 3
|
include_metadata |
❌ |
True , False
|
model_name |
❌ | Any string |
model_author |
❌ | Any string |
activation_function |
❌ | Any string |
uses_skip_connections |
❌ |
True , False
|
Note This function does not currently return anything, but a success boolean return is planned.
This function exports the passed model to a file created in the directory nexport is called from. In most cases, this is where the calling file is located. If you are using Jupyter, the file will be created where the notebook is located.
This function also outputs status updates to the terminal depending on the degree of verbosity passed.
Created and maintained by Jordan Welsman @ LBNL.
nexport
Copyright (c) 2022-2023, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Dept. of Energy).
All rights reserved.