Define the common interface among Clusters. More...
Public Types | |
typedef DoubleVector &(* | getStateVectorFuncPtr) (Cluster *) |
Delegate type for retrieving a vector by name (pointer to function) It works in this way: More... | |
Public Types inherited from ParameterSettable | |
enum | Property |
Public Member Functions | |
Cluster (unsigned int numNeurons, QString name="unnamed") | |
Construct a Cluster. More... | |
Cluster (ConfigurationParameters ¶ms, QString prefix) | |
Constructor. More... | |
virtual | ~Cluster () |
Destructor. More... | |
getStateVectorFuncPtr | getDelegateFor (QString stateVector) |
Return the pointer to function for retrieving the DoubleVector representing the state requested. More... | |
double | getInput (unsigned int neuron) const |
Get the input of neuron. More... | |
double | getOutput (unsigned int neuron) const |
Get the output of neuron. More... | |
DoubleVector & | inputs () |
Get the array of inputs. More... | |
const DoubleVector & | inputs () const |
Get the array of inputs. More... | |
bool | isAccumulate () const |
return true if the Cluster will accumulates inputs More... | |
bool | needReset () |
Return true if inputs needs a reset. More... | |
unsigned int | numNeurons () const |
Return the number of neurons (the length of input and output arrays) More... | |
OutputFunction * | outFunction () const |
Get the Output function. More... | |
DoubleVector & | outputs () |
Get the array of outputs. More... | |
const DoubleVector & | outputs () const |
Get the array of outputs. More... | |
virtual void | randomize (double min, double max)=0 |
Randomize the parameters of the Cluster The parameters randomized by this method will be specified by sub-classes. More... | |
void | resetInputs () |
Reset the inputs of this cluster; the inputs will be set to zero. More... | |
virtual void | save (ConfigurationParameters ¶ms, QString prefix) |
Save the actual status of parameters into the ConfigurationParameters object passed. More... | |
void | setAccumulate (bool mode) |
Enable/Disable accumulation mode If accumulation is enabled (true) then linkers attached to this Cluster will never resetInput and accumulates data, otherwise the inputs will be resetted at each step of neural network. More... | |
void | setAllInputs (double value) |
Set all the inputs with the same value Details... More... | |
void | setInput (unsigned int neuron, double value) |
Set the input of neuron Details... More... | |
void | setInputs (const DoubleVector &inputs) |
Set the inputs from the vector given. More... | |
void | setOutFunction (OutputFunction *up) |
Set the output function for all neurons contained This method create an internal copy of the OutputFunction passed More... | |
void | setOutput (unsigned int neuron, double value) |
Force the output of the neuron at value specified. More... | |
void | setOutputs (const DoubleVector &outputs) |
Set the outputs from the vector given. More... | |
Public Member Functions inherited from Updatable | |
Updatable (QString name="unnamed") | |
Constructor. More... | |
Updatable (ConfigurationParameters ¶ms, QString prefix) | |
Constructor. More... | |
virtual | ~Updatable () |
Destructor. More... | |
QString | name () const |
Return its name. More... | |
void | setName (QString newname) |
Set the name of Updatable. More... | |
virtual void | update ()=0 |
Update the object. More... | |
Public Member Functions inherited from ParameterSettableInConstructor | |
ParameterSettableInConstructor (ConfigurationParameters &, QString) | |
Public Member Functions inherited from ParameterSettable | |
void | addObserver (RuntimeParameterObserver *obs) |
T | getRuntimeParameter (QString paramName) |
virtual ParameterSettableUI * | getUIManager () |
virtual void | postConfigureInitialization () |
void | removeObserver (RuntimeParameterObserver *obs) |
void | setRuntimeParameter (QString paramName, T newvalue) |
QString | typeName () const |
Static Public Member Functions | |
static void | describe (QString type) |
Add to Factory::typeDescriptions() the descriptions of all parameters and subgroups. More... | |
Static Public Member Functions inherited from Updatable | |
static void | describe (QString type) |
Add to Factory::typeDescriptions() the descriptions of all parameters and subgroups. More... | |
Static Public Member Functions inherited from ParameterSettable | |
static void | describe (QString type) |
static QString | fullParameterDescriptionPath (QString type, QString param) |
static QString | fullSubgroupDescriptionPath (QString type, QString sub) |
Protected Member Functions | |
template<class T , DoubleVector &(T::*)() TMethod> | |
void | setDelegateFor (QString vectorName) |
Configure a delegate for a specifing state vector; who implements subclasses of Cluster has to specify a name and the method used to retrieve any state vector that needs to be public (i.e. More... | |
void | setNeedReset (bool b) |
Set the state of 'needReset' Used by subclasses into update implementation. More... | |
Protected Member Functions inherited from ParameterSettable | |
void | notifyChangesToParam (QString paramName) |
Additional Inherited Members | |
Public Attributes inherited from ParameterSettable | |
AllowMultiple | |
Default | |
IsList | |
IsMandatory | |
Static Public Attributes inherited from ParameterSettable | |
static const double | Infinity |
static const int | MaxInteger |
static const int | MinInteger |
Static Protected Member Functions inherited from ParameterSettable | |
static Descriptor | addTypeDescription (QString type, QString shortHelp, QString longHelp=QString("")) |
static void | setGraphicalEditor (QString type) |
Detailed Description
Define the common interface among Clusters.
- Motivation
- The Cluster class define the common interface amog Cluster. The subclasses may extends this interface for specific purpose (ex. SimpleCluster), but the BaseNeuralNet, the Linker and other classes depends only by this class. This abstraction allow to isolate the specific implementation of various classes
- Description
- The Cluster class represent an abstract group of neurons. There isn't a neuron class. The Cluster class represent a group of neurons as two arrays: inputs and outputs. The inputs array represent the inputs of the neurons 'contained' in the cluster, and the outputs of this neurons are calculated by appling the function provided by OutputFunction.
The number of neuron returned by size() method is also the dimension of inputs and outputs arrays
You can sets one subclasses of OutputFunction by setUpdater methods. If you don't specify an index when set a OutputFunction then this OutputFunction will be used to update the output of all neurons. Otherwise, you can specifiy different OutputFunction for different neuron.// create a SimpleCluster, a specialized subclass of ClusterSimpleCluster* simple = new SimpleCluster( 10 ); // this cluster contains 10 neurons// set the SigmoidUpdater for all neuronssimple->setUpdater( new SigmoidUpdater( 1.0 ) );
- Warnings
- For whose want to implement a subclass of Cluster: This class allocate the memory for inputs, outputs and updaters array. So, a subclass have to implements only the update method. The getInputs and getOutputs returns a valid array of internal data, and not simply a copy of the internal data. Look at the following code: The reasons behind this kind of behaviour its the efficiency!! When another class must do heavy calculation on all inputs of a Cluster (as MatrixLinker do), then its more efficient that it takes the array returned by inputs (or outputs) and works over them.RealVec& in = cluster->inputs();in[2] = 3.0; // This statement will be changes the inputs of third neuron.// the above statement is equivalent with the followingcluster->setInput( 2, 3.0 );
Member Typedef Documentation
typedef DoubleVector&(* getStateVectorFuncPtr) (Cluster *) |
Delegate type for retrieving a vector by name (pointer to function) It works in this way:
In the first row, getDelegateFor return a pointer to the function for retrieving the vector of biases. At the second row the delegate is used.
Look at the code of Linker and DotLinker for a full example on how to use it.
Constructor & Destructor Documentation
Cluster | ( | unsigned int | numNeurons, |
QString | name = "unnamed" |
||
) |
Construct a Cluster.
Definition at line 29 of file cluster.cpp.
References Cluster::numNeurons(), Cluster::setNeedReset(), and Cluster::setOutFunction().
Cluster | ( | ConfigurationParameters & | params, |
QString | prefix | ||
) |
Constructor.
Definition at line 44 of file cluster.cpp.
References ConfigurationHelper::getBool(), ConfigurationParameters::getObjectFromGroup(), ConfigurationHelper::getVector(), ConfigurationHelper::hasGroup(), Cluster::setNeedReset(), and Cluster::setOutFunction().
|
virtual |
Destructor.
Definition at line 86 of file cluster.cpp.
Member Function Documentation
|
static |
Add to Factory::typeDescriptions() the descriptions of all parameters and subgroups.
Definition at line 151 of file cluster.cpp.
References ParameterSettable::addTypeDescription(), Updatable::describe(), ParameterSettable::IsList, and ParameterSettable::IsMandatory.
Referenced by SimpleCluster::describe(), and BiasedCluster::describe().
|
inline |
Return the pointer to function for retrieving the DoubleVector representing the state requested.
- Parameters
-
stateVector is the name of the DoubleVector requested (i.e. "biases" in the case of the biases of a BiasedCluster)
- Note
- the class Cluster defines "inputs" and "outputs" that correspond to method inputs() and outputs()
- Warning
- It will raise an exception if the state requested does not exists
Definition at line 182 of file cluster.h.
Referenced by Linker::Linker().
double getInput | ( | unsigned int | neuron | ) | const |
Get the input of neuron.
Definition at line 113 of file cluster.cpp.
double getOutput | ( | unsigned int | neuron | ) | const |
Get the output of neuron.
Definition at line 125 of file cluster.cpp.
|
inline |
Get the array of inputs.
Definition at line 122 of file cluster.h.
Referenced by Cluster::setInputs(), SimpleCluster::update(), and BiasedCluster::update().
|
inline |
|
inline |
return true if the Cluster will accumulates inputs
Definition at line 97 of file cluster.h.
Referenced by Cluster::save().
|
inline |
|
inline |
Return the number of neurons (the length of input and output arrays)
Definition at line 82 of file cluster.h.
Referenced by BiasedCluster::BiasedCluster(), Cluster::Cluster(), LeakyIntegratorFunction::clusterSetted(), CompositeFunction::clusterSetted(), LinearComboFunction::clusterSetted(), BiasedCluster::randomize(), Pattern::setInputsOf(), Pattern::setInputsOutputsOf(), and Pattern::setOutputsOf().
|
inline |
Get the Output function.
Definition at line 149 of file cluster.h.
Referenced by SimpleCluster::update(), and BiasedCluster::update().
|
inline |
Get the array of outputs.
Definition at line 136 of file cluster.h.
Referenced by Cluster::setOutputs(), BackPropagationAlgo::setTeachingInput(), SimpleCluster::update(), and BiasedCluster::update().
|
inline |
|
pure virtual |
Randomize the parameters of the Cluster
The parameters randomized by this method will be specified by sub-classes.
Implemented in BiasedCluster, and SimpleCluster.
void resetInputs | ( | ) |
Reset the inputs of this cluster; the inputs will be set to zero.
Details...
Definition at line 108 of file cluster.cpp.
References Cluster::setNeedReset().
Referenced by NormLinker::update(), DotLinker::update(), and CopyLinker::update().
|
virtual |
Save the actual status of parameters into the ConfigurationParameters object passed.
This saves the name property, remember to call this in child classes
- Parameters
-
params the configuration parameters object on which save actual parameters prefix the prefix to use to access the object configuration parameters.
Reimplemented from Updatable.
Reimplemented in BiasedCluster, and SimpleCluster.
Definition at line 129 of file cluster.cpp.
References ConfigurationParameters::createParameter(), ConfigurationParameters::createSubGroup(), Cluster::isAccumulate(), Updatable::save(), and ConfigurationParameters::startObjectParameters().
Referenced by SimpleCluster::save(), BiasedCluster::save(), and NeuralNet::save().
|
inline |
void setAllInputs | ( | double | value | ) |
Set all the inputs with the same value Details...
Definition at line 103 of file cluster.cpp.
References Cluster::setNeedReset().
|
inlineprotected |
Configure a delegate for a specifing state vector; who implements subclasses of Cluster has to specify a name and the method used to retrieve any state vector that needs to be public (i.e.
used by Linkers for accessing and modifing it.
The usage is the following: suppose the case of BiasedCluster that has the biases vector and the metod biases() that returns the reference to the DoubleVector containing the biases. In this case, in the constructor there is the following statement:
where the first parameter of the template if the class with the new state vector, the second parameter is the method for getting the vector specified with the pointer-to-member syntax, and the name of the state vector (used for referencing it by name)
void setInput | ( | unsigned int | neuron, |
double | value | ||
) |
Set the input of neuron Details...
Definition at line 95 of file cluster.cpp.
void setInputs | ( | const DoubleVector & | inputs | ) |
Set the inputs from the vector given.
Definition at line 99 of file cluster.cpp.
References Cluster::inputs().
|
inlineprotected |
Set the state of 'needReset'
Used by subclasses into update implementation.
Definition at line 210 of file cluster.h.
Referenced by Cluster::Cluster(), Cluster::resetInputs(), Cluster::setAllInputs(), SimpleCluster::update(), and BiasedCluster::update().
void setOutFunction | ( | OutputFunction * | up | ) |
Set the output function for all neurons contained
This method create an internal copy of the OutputFunction passed
- Warning
- This function delete the previous updater class registered !!!
Definition at line 90 of file cluster.cpp.
Referenced by Cluster::Cluster().
void setOutput | ( | unsigned int | neuron, |
double | value | ||
) |
Force the output of the neuron at value specified.
Definition at line 117 of file cluster.cpp.
void setOutputs | ( | const DoubleVector & | outputs | ) |
Set the outputs from the vector given.
Definition at line 121 of file cluster.cpp.
References Cluster::outputs().
The documentation for this class was generated from the following files:
- nnfw/include/cluster.h
- nnfw/src/cluster.cpp