Main Page   Data Structures   File List   Data Fields   Globals  

nn.h File Reference

Main header file. More...

#include <stdio.h>

Go to the source code of this file.

Data Structures

struct  _nnLayer
 A layer of nodes. More...

struct  _nnLink
 A link between nodes. More...

struct  _nnNet
 A neural network. More...

struct  _nnNode
 A node. More...


Typedefs

typedef _nnLink nnLink
 A link between nodes.

typedef _nnNode nnNode
 A node.

typedef _nnLayer nnLayer
 A layer of nodes.

typedef _nnNet nnNet
 A neural network.

typedef enum _nnFileType nnFileType
 Return value for nnGuessFileType().


Enumerations

enum  _nnFileType { nnFileTypeUnknown, nnFileTypeBinary, nnFileTypeXML }
 Return value for nnGuessFileType(). More...


Functions

nnLayernnGetNetworkOutputLayer (nnNet *net)
 Returns the output layer of a network.

nnLayernnGetNetworkInputLayer (nnNet *net)
 Returns the input layer of a network.

double nnSigmoid (nnNode *node)
 Sigmoid function.

double nnDSigmoid (nnNode *node)
 Derivative of the sigmoid function.

void nnRunNetwork (nnNet *net)
 Evaluate each successive layer of a network, from input to output.

void nnSetNetworkInputs (nnNet *net, const double inputs[])
 Set the input nodes of a network from an array.

void nnGetNetworkOutputs (nnNet *net, double outputs[])
 Stores the states of all output nodes in a network into an array.

void nnCalculateOutputLayerError (nnLayer *layer, const double targets[])
 Calculate error of the output layer.

void nnCalculateHiddenLayerError (nnLayer *layer, nnLayer *nextLayer)
 Calculate error of a hidden layer.

void nnUpdateLayer (nnLayer *layer, nnNet *net)
 Update weights of a layer.

void nnUpdateNetwork (nnNet *net, const double targets[])
 Update weights of a network.

void nnUpdateLayerBatch (nnLayer *layer, nnNet *net)
 Update weight deltas of a layer.

void nnUpdateNetworkBatch (nnNet *net, double const targets[])
 Update weight deltas of a network.

void nnClearNetworkWeightDeltas (nnNet *net)
 Clear weight deltas of a network.

void nnUpdateNetworkWeights (nnNet *net)
 Update weights of a network using weight deltas.

int nnSaveNetwork (nnNet *net, void *handle, int(*nnWrite)(void *handle, void *data, size_t len))
 Save a network's topology and weights.

int nnSaveNetworkFile (nnNet *net, FILE *f)
 Save a network's topology and weights to a file.

int nnSaveNetworkMem (nnNet *net, void *data, size_t len)
 Save a network's topology and weights to memory.

int nnSaveNetworkDynMem (nnNet *net, void **ptr, size_t *len)
 Save a network's topology and weights to dynamically-allocated memory.

nnNetnnLoadNetwork (void *handle, int(*nnRead)(void *handle, void *data, size_t len))
 Load a network.

nnNetnnLoadNetworkFile (FILE *f)
 Load a network from a file.

nnNetnnLoadNetworkMem (void *data, size_t len)
 Load a network from memory.

nnFileType nnGuessFileType (FILE *f)
 Determines the type of a file.

int nnSaveNetworkXML (nnNet *net, FILE *f)
 Save a network's topology and weights to an XML-format file.

nnNetnnLoadNetworkXML (FILE *f)
 Load a network's topology and weights from an XML-format file.

double nnGetLayerError (nnLayer *layer)
 Calculate error of nodes in a layer.

double nnGetLayerRMSError (nnLayer *layer)
 Calculate RMS error of nodes in a layer.

void nnIterateNetworkNodes (nnNet *net, void(*f)(nnLayer *layer, nnNode *node, void *data), void *data)
 Call a function for each node in a network.

void nnIterateNetworkLinks (nnNet *net, void(*f)(nnNode *dest, nnLink *link, void *data), void *data)
 Call a function for each link in a network.

void nnDestroyNetwork (nnNet *net)
 free() a network and all associated structures.

nnNetnnCreateFullyConnectedNetwork (int nlayers, const int nnodes[])
 Create a fully-connected network.

nnNetnnCopyNetwork (nnNet *net)
 Make a deep-copy of a network.


Detailed Description

Main header file.


Enumeration Type Documentation

enum _nnFileType
 

Return value for nnGuessFileType().

Enumeration values:
nnFileTypeUnknown  File type is unknown.
nnFileTypeBinary  File type is binary.
nnFileTypeXML  File type is XML.


Function Documentation

void nnCalculateHiddenLayerError nnLayer   layer,
nnLayer   nextLayer
 

Calculate error of a hidden layer.

Parameters:
layer  Hidden layer.
nextLayer  The layer which the hidden layer feeds to.

void nnCalculateOutputLayerError nnLayer   layer,
const double    targets[]
 

Calculate error of the output layer.

Parameters:
layer  Output layer.
targets  Target values from which to calculate the error from.

nnNet* nnCopyNetwork nnNet   net
 

Make a deep-copy of a network.

Performs a deep-copy of a network. The new network will be an exact copy of source, having the same topology, weights, etc.

Parameters:
net  The network to copy.
Returns:
The new network or NULL on failure.

nnNet* nnCreateFullyConnectedNetwork int    nlayers,
const int    nnodes[]
 

Create a fully-connected network.

Creates a fully-connected neural network with nlayers layers. The first layer will have nnodes[0] nodes in it, the second layer will have nnodes[1] nodes in it, etc. The network will have a bias node.

Parameters:
nlayers  The number of layers in the network.
nnodes  An array of nlayers ints that specifies how many nodes to have in each layer.
Returns:
The network or NULL if the network couldn't be created.

void nnDestroyNetwork nnNet   net
 

free() a network and all associated structures.

Frees a network and all associated structures (layers, nodes, links). Any non-NULL structure pointers are recursively freed.

Parameters:
net  The network to free. May be NULL.

double nnDSigmoid nnNode   node
 

Derivative of the sigmoid function.

Parameters:
node  The nnNode to calculate the sigmoid derivative for.
Returns:
Sigmoid derivative calculated from node->in.

double nnGetLayerError nnLayer   layer
 

Calculate error of nodes in a layer.

Parameters:
layer  Layer to calculate error for.
Returns:
Error.

double nnGetLayerRMSError nnLayer   layer
 

Calculate RMS error of nodes in a layer.

Parameters:
layer  Layer to calculate error for.
Returns:
RMS error.

void nnGetNetworkOutputs nnNet   net,
double    outputs[]
 

Stores the states of all output nodes in a network into an array.

Parameters:
net  Network with output states to get.
outputs  Array where to store outputs.

nnFileType nnGuessFileType FILE *    f
 

Determines the type of a file.

Parameters:
f  stdio file handle.
Returns:
File type.

void nnIterateNetworkLinks nnNet   net,
void(*    f)(nnNode *dest, nnLink *link, void *data),
void *    data
 

Call a function for each link in a network.

Parameters:
net  The network to iterate over
f  Pointer to the function to call
data  Passed verbatim to the function

void nnIterateNetworkNodes nnNet   net,
void(*    f)(nnLayer *layer, nnNode *node, void *data),
void *    data
 

Call a function for each node in a network.

Calls func for each node in a network, including the bias node, if any. args is passed to func as the argument data. func's layer argument will be NULL for the bias node.

Parameters:
net  The network to iterate over
f  Pointer to the function to call
data  Passed verbatim to the function

nnNet* nnLoadNetwork void *    handle,
int(*    nnRead)(void *handle, void *data, size_t len)
 

Load a network.

Parameters:
handle  Opaque reading handle.
nnRead  Pointer to input function.
Returns:
Loaded network or NULL upon failure.

nnNet* nnLoadNetworkFile FILE *    f
 

Load a network from a file.

Parameters:
f  stdio file handle.
Returns:
Loaded network or NULL upon failure.

nnNet* nnLoadNetworkMem void *    data,
size_t    len
 

Load a network from memory.

Parameters:
data  Pointer to memory.
len  Length of memory.
Returns:
Loaded network or NULL upon failure.

nnNet* nnLoadNetworkXML FILE *    f
 

Load a network's topology and weights from an XML-format file.

Parameters:
f  stdio file handle.
Returns:
Loaded network, or NULL upon failure.

void nnRunNetwork nnNet   net
 

Evaluate each successive layer of a network, from input to output.

Parameters:
net  Network to evaluate.

int nnSaveNetwork nnNet   net,
void *    handle,
int(*    nnWrite)(void *handle, void *data, size_t len)
 

Save a network's topology and weights.

Parameters:
net  Network to save.
handle  Opaque writing handle.
nnWrite  Pointer to output function.
Returns:
1 if successful, 0 otherwise.

int nnSaveNetworkDynMem nnNet   net,
void **    ptr,
size_t *    len
 

Save a network's topology and weights to dynamically-allocated memory.

Parameters:
net  Network to save.
Return values:
ptr  Upon success, will contain pointer to saved network in memory.
len  Upon success, will contain length of saved network.
Returns:
1 if successful, 0 otherwise.

int nnSaveNetworkFile nnNet   net,
FILE *    f
 

Save a network's topology and weights to a file.

Parameters:
net  Network to save.
f  stdio file handle.
Returns:
1 if successful, 0 otherwise.

int nnSaveNetworkMem nnNet   net,
void *    data,
size_t    len
 

Save a network's topology and weights to memory.

Parameters:
net  Network to save.
data  Memory location to store network.
len  Size of memory.
Returns:
1 if successful, 0 otherwise.

int nnSaveNetworkXML nnNet   net,
FILE *    f
 

Save a network's topology and weights to an XML-format file.

Parameters:
net  Network to save.
f  stdio file handle.
Returns:
1 if successful, 0 otherwise.

void nnSetNetworkInputs nnNet   net,
const double    inputs[]
 

Set the input nodes of a network from an array.

Parameters:
net  Network with inputs to set.
inputs  Array of from which to set the inputs.

double nnSigmoid nnNode   node
 

Sigmoid function.

Parameters:
node  Pointer to the nnNode for which to calculate the sigmoid value for.
Returns:
Sigmoid value calculated from node->in.

void nnUpdateLayer nnLayer   layer,
nnNet   net
 

Update weights of a layer.

Parameters:
layer  Layer to update.
net  Network which layer is from.

void nnUpdateNetwork nnNet   net,
const double    targets[]
 

Update weights of a network.

Parameters:
net  Network to adjust weights of.
targets  Output target values.


Generated on Sat Feb 22 03:39:25 2003 for nn by doxygen1.2.18