Welcome to our Support Center

Average

Description

Setup and add the average layer into the model during the definition graph step. Type : polymorphic.

 

Input parameters

 

Graphs in : array, model architecture.

parameters : layer parameters.

training? : boolean, whether the layer is in training mode (can store data for backward).
Default value “True”.
lda_coeff : float, defines the coefficient by which the loss derivative will be multiplied before being sent to the previous layer (since during the backward run we go backwards).
Default value “1”.

 output_behavior : enum, setup if the layer is an output layer.
Default “Not Output”​.

name (optional) : string, name of the layer.

 

Output parameters

 

Graph out : model architecture.

Dimension

Input shape

All layers used for averaging must have the same output shape.
Refer to the output shape of the layer tensor used.

 

Output shape

Same as input shape.

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 HAIBAL library to run it).

Average layer with two identical input layer shape

1 – Generate a set of data

We generate an array of data of type single and shape [batch_size = 10, input_dim = 5] (same input shape).

2 – Define graph

We first define two input layers named input_dense1 and input_dense2. This layers is setup as an input array shaped [input_dim = 5].
In order to have same output shape for added dense layers we define for both of these the same “units” parameter (units = 5) (refer Dense layer add to graph documentation for more details).
Then we build an array of the two graphs generated by the dense layers and inject it into the input of the Average layer.

3 – Summarize graph

Returns the summary of the model in file text.

4 – Run graph

We call the forward method and retrieve the result with the “Prediction 2D” method.
This method returns two variables, the first one is the layer information (cluster composed of the layer name, the graph index and the shape of the output layer) and the second one is the prediction with a shape of [batch_size, units] (Dense output shape).

 

Average layer with two different input layer shape

1 – Generate a set of data

We generate two array of data of type single and shape1 [batch_size = 10, input_dim = 5] and shape2 [batch_size = 10, input_dim = 15] (different input shape).

2 – Define graph

We first define two input layers named input_dense1 and input_dense2. This layers is setup as an input array shaped [input_dim = 5] and [input_dim = 15].
In order to have same output shape for added dense layers we define for both of these the same “units” parameter (units = 5) (refer Dense layer add to graph documentation for more details).
Then we build an array of the two graphs generated by the dense layers and inject it into the input of the Average layer.

3 – Summarize graph

Returns the summary of the model in file text.

4 – Run graph

We call the forward method and retrieve the result with the “Prediction 2D” method.
This method returns two variables, the first one is the layer information (cluster composed of the layer name, the graph index and the shape of the output layer) and the second one is the prediction with a shape of [batch_size, units] (Dense output shape).

 

Table of Contents