Welcome to our Support Center

Load all weights by name

Description

Load weights in the model. The table of weights is authentic, it defines the names for which weights are loaded, the others will be initialized randomly. You can choose to display a log file in .txt or .csv format to resume the model architecture and the loading of weights.

Input parameters

 

Model in : model architecture.
 file_type : enum, type of the file on which the summary is written.

    • None : returns the summary only in a cluster array.
    • txt : returns the summary in a text file and cluster array. (default)
    • csv : returns the summary in a comma-separated values (csv) file and cluster array.

 weight_array : cluster

 name : string, name of layer.
 weights : variant, weight value.

Output parameters

 

Model out : model architecture.

Example

All these exemples are snippets PNG, you can drop these Snippet onto the block diagram and get the depicted code added to your VI (Do not forget to install Deep Learning library to run it).

Using the “Set Weights by name” function

1 – Define Graph

We define the graph with one input and two Dense layers named Dense1 and Dense2.

2 – Set Function

We use the “Set Weights by name” function to set weights for the layers named Dense1 and Dense2.

3 – Get Function

We use the “Get All Weights” function to get the weights of all layers that have them from the model.

4 – Index weight_array

Since the only layers that have weights are Dense1 and Dense2 we index the array returned by the get function to retrieve their weight.

5 – Convert variant to data

The get function returns the weights in a variant, so we use the “Variant To Data” function of LabVIEW to get the result in an array. For that, we use the polymorph which transmits us directly the typedef of the Dense layer.

Tags:
Table of Contents