gnn_node shouldn't be used by themself. Instead, new node types extend the gnn_node data type.
The conventions for notation used throughout this documentation is:
A gnn_node implements a set
of vectorial functions
that map an input vector
of size
to an ouput vector
of size
. This set can be a singleton, or, optionally, it can have a vector of adjustable parameters
of size
so that
In this case, we will talk about the "generic" function
as the "Machine" or the "Model".
A general machine
can be built by connecting several subfunctions in a variety of forms. The resulting function can then be feed with inputs to compute its output. Since libgnn's main purpose is to offer a unified way to train this function using the error-backpropagation scheme to compute the function's gradient with respect to its parameters
, the gnn_node structure has been designed to provide a simple yet powerful extendable skeleton for the implementation of highly customized models.
The evaluation of the result is the Forward Evaluation, triggered by the gnn_node_evaluate_f function, and the computation of both gradient is called Backward Evaluation, triggered (in order) by gnn_node_evaluate_dx and gnn_node_evaluate_dw .
In order to compute the result and the gradients for one (and only one!) given input example, you should call, in order:
More about extensions:
Although all specific extensions have their own specific features, they all are (or can be casted to) a gnn_node. A gnn_node can be manipulated with the following APIs:
and
.Modules | |
| gnn_node Parameters API | |
| Set of functions for the manipulation of a node's parameters. | |
| gnn_node Extension API | |
| A set of functions for implementing an extension of gnn_node. | |
| gnn_node Subnodes API | |
| The API for connecting and traversing trees of nodes. | |
| gnn_node_vector : Vector of nodes. | |
| gnn_pbundle : A Unified View of Parameter Sets. | |
| Provides a unified view of multiple parameters. | |
| gnn_phandle : A Handle for Parameters. | |
| Handle for managing a set of parameters. | |
Functions | |
| int | gnn_node_is_root (gnn_node *node) |
| Check if node is root node. | |
| const char * | gnn_node_get_type_name (gnn_node *node) |
| Get the node's type. | |
| int | gnn_node_input_get_size (gnn_node *node) |
| Get the node's input size. | |
| int | gnn_node_output_get_size (gnn_node *node) |
| Get the node's output size. | |
| int | gnn_node_destroy (gnn_node *node) |
| Destroys the current node. | |
| int | gnn_node_evaluate_f (gnn_node *node, const gsl_vector *x, gsl_vector *y) |
| Evaluates the output of the function recursively. | |
| int | gnn_node_evaluate_init (gnn_node *node) |
| Initializes the evaluations. | |
| int | gnn_node_evaluate_dx (gnn_node *node, const gsl_vector *dy, gsl_vector *dx) |
Evaluates the gradient
. | |
| int | gnn_node_evaluate_dw (gnn_node *node, gsl_vector *dw) |
Evaluates the gradient
. | |
|
|
This function detroys the node given as a parameter: it calls first the installed destructor and the gnn_node Extension API to destroy itself. This is a virtual function: the specific destruction of the node is given by the installed gnn_node::destroy function, and the destruction of the underlying's node structure by itself is performed by gnn_node Extension API.
Definition at line 500 of file gnn_node.c. |
|
||||||||||||
|
This function computes
@warning: The
Definition at line 653 of file gnn_node.c. |
|
||||||||||||||||
|
This function computes
@warning: The
Definition at line 609 of file gnn_node.c. |
|
||||||||||||||||
|
This function computes the output of the node's function. First, it sets the appropiate values for initiating the recursive evaluation, and then calls gnn_node Extension API.
@warning: If you want to compute
Definition at line 538 of file gnn_node.c. |
|
|
This function initializes the gradient evaluation routines. It should be called before gnn_node Extension API, for every single pattern or input evaluation. The complete sequence for evaluations is:
Definition at line 579 of file gnn_node.c. |
|
|
This function returns the node's type: an unique string which identifies a node's type. Generally speaking, the type depends on which constructor function was used to instantiate the node. Per example, gnn_weight_new () creates a "gnn_weight" node, gnn_tanh_new () creates a "gnn_tanh" node. The returned string is owned by the node and should not be freed or manipulated in any other way.
Definition at line 440 of file gnn_node.c. |
|
|
This function returns the size
Definition at line 458 of file gnn_node.c. |
|
|
This function returns 1 if the current node is a root node, or 0 if not.
Definition at line 413 of file gnn_node.c. |
|
|
This function returns the size
Definition at line 475 of file gnn_node.c. |
1.2.18