Every gnn_node contains a set of parameters (it can be empty of course). By changing them, the function's behaviour is changed. Formally, the parameters allow the model to be adapted to a particular case. It is, therefore, very important to provide extended functionality for manipulating them.
Every node contains two types of parameters:
When two nodes A and B are composed using a third node C, then C will be at the root, and will provide direct access to all parameters (that is, the parameters of the whole tree):
This is absolutely transparent to the programmer. Note that each node knows exactly which ones are its local parameters, but to get direct access to them, use the extension API.
Note that in general, a node which is not a leaf rarely posseses its own parameters.
The good thing here is that you gain direct access to the new (concatenated) parameter as it were a single vector.
There are two more objects you should know of: the gradient with respect to the parameters, and the freeze flags, both vectors of the same size as the parameter vector. The first is a buffer, were the gradient should be computed. The second is a special flag vector: they specify if a given parameter is actually free to be changed (free parameter) of if it has been frozen (and can't be changed). These additional vectors can also be manipulated using this interface.
Some technical details:
So, the node accesses its local parameters (which are some kind of "global" and independent entities that can perfectly be shared with other nodes) through a parameter handle.
Simultaneously, the node also posseses a special parameter bundle, which gives him access to the whole tree's parameters.
Although it can be useful to know about the internal details of the parameter managing and its implementation, the gnn_node Parameters API provides a transparent set of functions to manipulate them. The important things to note are:
Functions | |
| int | gnn_node_param_get_size (gnn_node *node) |
| Returns the size of the parameter vector. | |
| int | gnn_node_param_get (gnn_node *node, gsl_vector *w) |
| Get the node's parameters. | |
| int | gnn_node_param_set (gnn_node *node, const gsl_vector *w) |
| Sets new values for the parameter vector. | |
| int | gnn_node_param_freeze_flags_get (gnn_node *node, gsl_vector_int *f) |
| Get the freeze flags. | |
| int | gnn_node_param_freeze_flags_set (gnn_node *node, const gsl_vector_int *f) |
| Sets new freeze flags. | |
| int | gnn_node_param_freeze (gnn_node *node, int i) |
| Freeze the i-th parameter. | |
| int | gnn_node_param_unfreeze (gnn_node *node, int i) |
| Unfreeze the i-th parameter. | |
| int | gnn_node_param_is_frozen (gnn_node *node, int i) |
| Check if the i-th parameter is frozen. | |
| int | gnn_node_param_are_frozen (gnn_node *node) |
| Check if all the node's parameters are frozen. | |
| int | gnn_node_param_freeze_all (gnn_node *node) |
| Freeze all parameters. | |
| int | gnn_node_param_unfreeze_all (gnn_node *node) |
| Unfreeze all parameters. | |
| int | gnn_node_param_share (const gnn_node *node, gnn_node *client) |
| Share the node's parameters. | |
|
|
This function returns 1 if all parameters are frozen.
Definition at line 912 of file gnn_node.c. |
|
||||||||||||
|
This function freezes the i-th parameter.
Definition at line 862 of file gnn_node.c. |
|
|
This function freezes all the node's parameters.
Definition at line 931 of file gnn_node.c. |
|
||||||||||||
|
This function fills the given integer vector f with the node's freeze flags. Implementation Note: The parameter vector is build with the node's parameter bundle.
Definition at line 826 of file gnn_node.c. |
|
||||||||||||
|
This function sets new freeze flags for the node. They should be given as a
Definition at line 845 of file gnn_node.c. |
|
||||||||||||
|
This function fills the input buffer w with the node's parameter values. Implementation Note: The parameter vector is build with the node's parameter bundle.
Definition at line 786 of file gnn_node.c. |
|
|
This function returns
Definition at line 766 of file gnn_node.c. |
|
||||||||||||
|
This function returns 1 if the i-th parameter is frozen.
Definition at line 896 of file gnn_node.c. |
|
||||||||||||
|
This function sets new values for the node's parameter vector. The new values are taken by the buffer w (of the correct size) given as input argument.
Definition at line 805 of file gnn_node.c. |
|
||||||||||||
|
This function share the node's parameters with the client node. @warning: This function should be called on nodes that aren't connected only.
Definition at line 966 of file gnn_node.c. |
|
||||||||||||
|
This function unfreezes the i-th parameter.
Definition at line 879 of file gnn_node.c. |
|
|
This function unfreezes all the node's parameters.
Definition at line 947 of file gnn_node.c. |
1.2.18