www.pudn.com > 基于VC的神经网络开发程序包(源码).rar > RadialBasisNetwork.h
#ifndef _RADIALBASISNETWORK_H
#define _RADIALBASISNETWORK_H
#include "Network.h"
#include "SimpleNeuron.h"
#include "CenterNeuron.h"
#include "InputLayer.h"
#include "TrainingSet.h"
namespace annie
{
/** A Radial Basis Function Neural Network.
*
* The network consists of a layer of N-inputs, then h-(N-dimensional) centers, and
* some outputs.
* The default activation function for the centers is gaussian(), which is the gaussian
* distribution function with sigma = 1. If you want to change that then you'll have
* to write your own activation function and change it with setCenterActivationFunction().
* The output neurons use the identity() function as the activation function, thus the
* output is simply the weighted sum of the outputs of the centers.
*
* There are atleast two ways to train a radial basis network.
*
* One involves fixed centers and training the weights only in order to minimize
* the error over a training set. The other involves using the gradient descent
* rule to adjust both centers and weights. Currently only the former is implemented
* in annie using trainWeights().
*
* @see trainWeights
* \todo Implement gradient-descent rule based updation of centers and weights
* \todo The copy constructor
*/
class RadialBasisNetwork : public Network
{
protected:
/** Number of centers in the network.
* If you plan to extend this class, then the onus of keeping this value
* consistent lies on you
*/
int _nCenters;
/// Layer of input. Each member is an InputNeuron
InputLayer *_inputLayer;
/// Layer of centers, each member is a CenterNEuron
Layer *_centerLayer;
/// Layer of output, each member if a SimpleNeuron
Layer *_outputLayer;
public:
/** Creates a Radial basis function network. All the outputs will have a bias.
* @param inputs Number of inputs taken in by the network
* @param centers Number of centers the network has. Each center will be
* an inputs-dimensional point
* @param outputs The number of outputs given by the neuron. All of them will have
* a bias
*/
RadialBasisNetwork(int inputs, int centers, int outputs);
/** Loads a network from a text file
* @see save
* @param filename Name of the file from which to load network structure
* @throws Exception On any error
*/
RadialBasisNetwork(const char *filename);
/// Copy constructor, NOT YET IMPLEMENTED
RadialBasisNetwork(RadialBasisNetwork &srcNet);
virtual ~RadialBasisNetwork();
/** Sets the ith center point to the given point.
* @param i The center that is to be changed
* @param center The getInputCount() dimensional point
*/
virtual void setCenter(int i, VECTOR ¢er);
/** Sets the ith center point to the given point.
* @param i The center that is to be changed
* @param center The getInputCount() dimensional point
*/
virtual void setCenter(int i, real *center);
/** Returns the point corresponding to the ith center.
* @param i The center whose point is wanted
* @return The getInputCount() dimensional point corresponding to the
* ith center
*/
virtual VECTOR getCenter(int i);
/// The number of centers in the network
virtual int getCenterCount();
/** Sets the bias of the ith output.
* @param i The index of the output (0<=i