Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

gnn_criterion.h File Reference

#include "gnn_globals.h"

Include dependency graph for gnn_criterion.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Data Structures

struct  _gnn_criterion

Typedefs

typedef _gnn_criterion gnn_criterion
 The datatype for criterions.

typedef double(* gnn_criterion_e )(gnn_criterion *crit, const gsl_vector *y, const gsl_vector *t)
 The datatype for criterions evaluation functions.

typedef int(* gnn_criterion_dy )(gnn_criterion *crit, const gsl_vector *y, const gsl_vector *t, gsl_vector *dy)
 The datatype for .

typedef void(* gnn_criterion_destructor )(gnn_criterion *crit)
 The datatype for destructors for criterion extensions.


Functions

int gnn_criterion_init (gnn_criterion *crit, const char *type, size_t size, gnn_criterion_e e, gnn_criterion_dy dy, gnn_criterion_destructor destroy)
 Initializes a gnn_criterion : Basic Criterion Function..

size_t gnn_criterion_get_size (gnn_criterion *crit)
 Returns a criterion's size.

const char * gnn_criterion_get_type (gnn_criterion *crit)
 Returns the name of the criterion.

double gnn_criterion_evaluate_e (gnn_criterion *crit, const gsl_vector *y, const gsl_vector *t)
 Evaluates the criterion.

int gnn_criterion_evaluate_dy (gnn_criterion *crit, gsl_vector *dy)
 Evaluates the criterion's gradient.

void gnn_criterion_destroy (gnn_criterion *crit)
 Destroys the criterion.

int gnn_criterion_eval_dy (gnn_criterion *crit, gsl_vector *dy)
 Evaluates the criterion's gradient.


Function Documentation

void gnn_criterion_destroy gnn_criterion   crit
 

This function destroys a given criterion structure by freeing its memory.

It will call the specific destroy function (if any) for the criterion, which was previosly installed. Then it frees the fields of gnn_criterion : Basic Criterion Function. and the structure itself.

Parameters:
crit  A pointer to a gnn_criterion : Basic Criterion Function..

Definition at line 365 of file gnn_criterion.c.

int gnn_criterion_eval_dy gnn_criterion   crit,
gsl_vector *    dy
 

This function evaluates the criterion's gradient with respect to the last evaluated estimation and target and ADDS the result to the vector pointed by "dy". It is important to note the following rules:

  • This function is called by gnn_criterion_evaluate_dy.
  • Composed criterions, which depend on inner subcriterions often need to compute their gradient as the result of summing up their subgradients.
This is why the evaluation of the gradient has been split up into the base function gnn_criterion_evaluate_dy (which clears the buffer "dy" first) and this function.

This function calls the criterion's specific gradient function.

Parameters:
crit  A pointer to a gnn_criterion : Basic Criterion Function..
dy  A pointer to a buffer vector of the correct size where the gradient is added up.
Returns:
Returns 0 if succeeded.

Definition at line 345 of file gnn_criterion.c.

int gnn_criterion_evaluate_dy gnn_criterion   crit,
gsl_vector *    dy
 

This function evaluates the criterion's gradient with respect to the last evaluated estimation and target . The gradient always is of the same size. Internally, it clears the buffer "dy" (where the resulting gradient should be placed in) and then calls gnn_criterion_evaluate.

Parameters:
crit  A pointer to a gnn_criterion : Basic Criterion Function..
dy  A pointer to a buffer vector of the correct size for storing the gradient.
Returns:
Returns 0 if succeeded.

Definition at line 309 of file gnn_criterion.c.

double gnn_criterion_evaluate_e gnn_criterion   crit,
const gsl_vector *    y,
const gsl_vector *    t
 

This function evaluates the criterion for the given vectors "y" and "t", which are (usually) the Models output and the desired target vector .

It will call the specific evaluation function for the criterion, which was previosly installed.

Parameters:
crit  A pointer to a gnn_criterion : Basic Criterion Function..
y  A pointer to a vector (the estimation).
t  A pointer to a vector (the target).
Returns:
The value of the criterion.

Definition at line 279 of file gnn_criterion.c.

size_t gnn_criterion_get_size gnn_criterion   crit
 

This functions returns the size of the vectors and .

Parameters:
crit  A pointer to a gnn_criterion : Basic Criterion Function..
Returns:
Returns the size.

Definition at line 237 of file gnn_criterion.c.

const char* gnn_criterion_get_type gnn_criterion   crit
 

This functions returns a string which identifies uniquely the current criterion's type.

Parameters:
crit  A pointer to a gnn_criterion : Basic Criterion Function..
Returns:
Returns a non-modifiable string.

Definition at line 255 of file gnn_criterion.c.

int gnn_criterion_init gnn_criterion   crit,
const char *    type,
size_t    size,
gnn_criterion_e    e,
gnn_criterion_dy    dy,
gnn_criterion_destructor    destroy
 

This function initializes a gnn_criterion : Basic Criterion Function. by setting its size and installing the specific functions for , and the destructor.

It is mandatory to provide:

  • A size that is stricly positive.
  • The evaluation function.
  • The gradient evaluation function.
If the destructor is ommitted (by giving NULL as argument), then it will be assumed that no special deallocation is necessary for the extension.

In example, suppose you want to implement a criterion called "my_criterion" and that you have already coded the evaluation function and the gradient function, which you called "my_criterion_e" and "my_criterion_dy" respectivelly. Your criterion doesn't need any additional data to compute them, so you didn't extend the basic gnn_criterion : Basic Criterion Function.. Then, the code would be a template for the constructor:

   gnn_criterion *
   my_criterion_new (size_t size)
   {
       int status;
       gnn_criterion *crit;
       
       // allocate memory for the criterion
       crit = (gnn_criterion *) malloc (sizeof (gnn_criterion));
       
       // initialize
       status = gnn_criterion_init (crit, "my criterion", size,
                       my_criterion_e, my_criterion_dy, my_criterion_destroy);
       if (status)
           print_an_error_message_and_return_null ();

       // return
       return crit;
   }
Parameters:
crit  A pointer to a gnn_criterion : Basic Criterion Function..
type  A string containing the name of the criterion.
size  The size of the input vectors and .
e  A pointer to the evaluation function.
dy  A pointer to the gradient evaluation function.
destroy  A pointer to the destructor function.
Returns:
Returns 0 if the initialization could be performed with success.

Definition at line 181 of file gnn_criterion.c.


Generated on Sun Jun 13 20:50:24 2004 for libgnn Gradient Retropropagation Machine Library by doxygen1.2.18