-
Notifications
You must be signed in to change notification settings - Fork 4
Intermediate JSON Schema
Within the Neural-Network-Translator the frontend-plugins transform a given network model created with a specific framework into an intermediate format, which can be translated into an executable form for a specific backend.
In the following, the intermediate format will be described in more detail to understand what happens in a frontend plugin.
The correctness of the generated network model is checked after the transformation by the respective frontend plugin during the program run of the Neural-Network-Translator. The program run is aborted if the result does not correspond to the defined schema.
The intermediate format was created as JSON and, therefore, can easily be generated and read in Python.
The basic structure of the format looks like follows:
{
"class_name" : <type of the network>,
"config" : {
"name" : <name of the network>,
"layers" : [
{
"class_name" : <type of the layer>,
"config" : <configuration of the layer>
},
...
]
}
}
The configuration of the layer can contain multiple attributes which define the behavior of the layer.
The following attributes are valid entries in the configuration object:
Key | Value |
---|---|
batch_input_shape | Shape of the input values. For example: [null,8]
|
dtype | Type of the input values |
units | Number of neurons in the layer |
activation | Name of the used activation function |
use_bias | Boolean indicating if bias values are used in the layer |
kernel_values | Weight values for the calculation process |
bias_values | Bias values for the calculation process if use_bias = True
|
data_format |
channels_last or channels_first in order of the input format |
pool_size | Array with the size of the pooling kernel. For example: [2,2]
|
padding |
same if padding is used or valid if not |
strides | Array with the stride size. For example: [2,2]
|
The following code is of an exemplary network with a dense layer:
{
"class_name": "Sequential",
"config": {
"name": "sequential_1",
"layers": [
{
"class_name": "Dense",
"config": {
"name": "dense_1",
"batch_input_shape": [
null,
8
],
"dtype": "float32",
"units": 8,
"activation": "sigmoid",
"use_bias": true
},
"kernel_values": [...],
"bias_values": [...]
}, ...
], ...
}
}