NeuralNet Class Reference
The Neural Network Class. More...

Public Member Functions | |
NeuralNet () | |
Construct an empty neural network. | |
~NeuralNet () | |
Destructor. | |
void | addCluster (Cluster *c, bool isInput=false, bool isOutput=false) |
Add a Cluster into the neural network If isInput is true then the Cluster will be considered as an Input Cluster of this network If isOutput is true then the Cluster will be considered as an Output Cluster of this network. | |
void | addInputCluster (Cluster *c) |
Add a Cluster and mark it as Input Behave exactly the same of addCluster( c, true, false ) | |
void | addLinker (Linker *l) |
Add Linker. | |
void | addOutputCluster (Cluster *c) |
Add a Cluster and mark it as Output Behave exactly the same of addCluster( c, false, true ) | |
template<class PointerTo > | |
PointerTo | byName (QString aName, PointerTo &aPointer) |
Search into the net for the presence of an Updatable with name aName; on success set the pointer aPointer and return it, otherwise it set aPointer to zero and return zero. | |
ClusterList | clusters () const |
Returns the vector of Clusters contained. | |
virtual void | configure (ConfigurationParameters ¶ms, QString prefix) |
Configures the object using a ConfigurationParameters object. | |
bool | find (const Cluster *) const |
Return true if the Cluster is in this net. | |
bool | find (const Updatable *) const |
Return true if the Updatable object is in this net. | |
bool | find (const Linker *) const |
Return true if the Linker is in this net. | |
Updatable * | getByName (QString) |
Return the Updatable with the name specified Returns NULL-pointer if there's no updatable object whit the name specified | |
ClusterList | hiddenClusters () const |
Returns the vector of Hidden Clusters contained (i.e. | |
ClusterList | inputClusters () const |
Returns the vector of Input Clusters contained. | |
bool | isIsolated (Cluster *c) const |
Return true if there isn't any Linker connected with Cluster c. | |
LinkerList | linkers () const |
Returns the array of Linkers contained. | |
LinkerList | linkers (Cluster *c, bool out=false) const |
If out is true, return the Linkers outgoing from Cluster c, otherwise return incoming Linkers. | |
void | markAsInput (Cluster *c) |
Mark a Cluster as an Input Cluster of this network. | |
void | markAsOutput (Cluster *c) |
Mark a Cluster as an Output Cluster of this network. | |
QString | name () |
return the name of the NeuralNet | |
UpdatableList | order () const |
Return the order. | |
ClusterList | outputClusters () const |
Returns the vector of Output Clusters contained. | |
void | randomize (double min, double max) |
This randomize the free parameters of the all elements of the neural net This method call randomize method of every Cluster and Linker inserted. | |
bool | removeCluster (Cluster *c) |
Remove a Cluster from the network. | |
bool | removeLinker (Linker *) |
Remove Linker. | |
virtual void | save (ConfigurationParameters ¶ms, QString prefix) |
Save the actual status of parameters into the ConfigurationParameters object passed. | |
void | setName (QString name) |
Set the name of the NeuralNet It's useful when loading from ConfigurationParameters more than NeuralNet or from LearningAlgorithms subclasses. | |
void | setOrder (const UpdatableList &) |
Set the order. | |
void | setOrder (Updatable *updatables[], unsigned int dim) |
Set the order. | |
void | step () |
Step. | |
void | unmark (Cluster *c) |
Eliminate the marks from Cluster passed. | |
void | unmarkAll () |
Eliminate the marks from all Cluster present in this networks. | |
Static Public Member Functions | |
static void | describe (QString type) |
Add to Factory::typeDescriptions() the descriptions of all parameters and subgroups. | |
Protected Types | |
typedef QMap< QString, Cluster * > | ClustersMap |
typedef QMap< QString, Linker * > | LinkersMap |
typedef QMap< Cluster *, LinkerList > | LinkVecMap |
Protected Attributes | |
ClustersMap | clsMap |
map name -> Cluster* | |
ClusterList | clustersv |
Clusters. | |
unsigned int | dimUps |
ClusterList | hidclusters |
unmarked Clusters | |
ClusterList | inclusters |
Input Clusters. | |
LinkVecMap | inLinks |
mappa dei linkers entranti (cluster -> vettore linkers entranti) | |
LinkerList | linkersv |
Linkers. | |
LinkersMap | lksMap |
map name -> Linker* | |
QString | namev |
name of this NeuralNet | |
ClusterList | outclusters |
Output Clusters. | |
LinkVecMap | outLinks |
map of outgoing linkers (cluster -> vettore linkers uscenti) | |
UpdatableList | ups |
Array of Updateables ordered as specified. |
Detailed Description
The Neural Network Class.
The NeuralNet class can seen as a simple container of Clusters and Linkers
The relationship among Clusters and Linkers must be specified by cluster and linker constructors;
When the NeuralNet is configured from a file, it is configured in the following way:
- the parameters for configuring a NeuralNet are: inputClusters, outputClusters, spreadOrder, clustersList, linkersList; all parameters consist in a list of the group name where is present the corresponding object configuration
- the only mandatory parameter is spreadOrder
- inputClusters is the list of all Clusters considered the input layer of the NeuralNet
- outputClusters is the list of all Clusters considered the output layer of the NeuralNet
- clustersList and LinkersList are the full list of all Clusters and Linkers to put into the network; in some cases, these parameters are redundant, because if a Cluster or a Linker is specified into spreadOrder then it will be automatically put into to the NeuralNet
- all sub-groups of the group containing the parameters of NeuralNet are considered object to be created and to be put into the NeuralNet
Some examples of configuration files using the INI format. The first example shows how to create a NeuralNet with two Cluster as input and one Cluster as output connected by two linkers. This example uses all parameters even if some are redundant
inputClusters = input1 input2 outputClusters = output1 spreadOrder = input1 input2 linker1 linker2 output1 clustersList = input1 input2 output1 linkersList = linker1 linker2 [input1] type = FakeCluster [input2] type = SimpleCluster [input2/OutFunction] type = StepFunction min = -1.0 max = +1.0 threshold = 0.5 [output1] type = BiasedCluster [output1/OutFunction] type = SigmoidFunction lambda = 0.5 [linker1] type = DotLinker from = input1 to = output1 [linker2] type = DotLinker from = input2 to = output1
The same NeuralNet can be configured without specifing clustersList and linkersList with the following file INI:
inputClusters = input1 input2 outputClusters = output1 spreadOrder = input1 input2 linker1 linker2 output1 [input1] type = FakeCluster [input2] type = SimpleCluster [input2/OutFunction] type = StepFunction min = -1.0 max = +1.0 threshold = 0.5 [output1] type = BiasedCluster [output1/OutFunction] type = SigmoidFunction lambda = 0.5 [linker1] type = DotLinker from = input1 to = output1 [linker2] type = DotLinker from = input2 to = output1
Let's suppose that you want to change the NeuralNet of the example above removing input1 as input Cluster of the NeuralNet then the two following configurations results in the same NeuralNet:
inputClusters = input2 outputClusters = output1 spreadOrder = input1 input2 linker1 linker2 output1 ...
inputClusters = input2 outputClusters = output1 spreadOrder = input2 linker1 linker2 output1 ...
Because even if in the last example the input1 is not specified in any of the NeuralNet parameters, it will be created because [input1] is a subgroup of the main group where the NeuralNet parameters are present
To understand better this situation, let's put all NeuralNet parameters into a group called [Net1], the above example will appear in this way:
[Net1] inputClusters = input2 outputClusters = output1 spreadOrder = input2 linker1 linker2 output1 [input1] type = FakeCluster [input2] type = SimpleCluster [input2/OutFunction] type = StepFunction min = -1.0 max = +1.0 threshold = 0.5 [output1] type = BiasedCluster [output1/OutFunction] type = SigmoidFunction lambda = 0.5 [linker1] type = DotLinker from = input1 to = output1 [linker2] type = DotLinker from = input2 to = output1
Now the input1 will be not automatically added to the NeuralNet because the group [input1] is not anymore a subgroup of the group ([Net1]) where the NeuralNet parameters are present. In this case, if you want that also [input1] will be put into the NeuralNet you have two options:
- change the group of [input1] to [Net1/input1]; but this also means that the corresponding Cluster will be named "Net1/input1" instead of "input1"
- add a clustersList parameter where you declare the complete list of Clusters including input1; in this way the name of the Cluster will remain "input1" The two alternatives appear in the following way:
[Net1] inputClusters = input2 outputClusters = output1 spreadOrder = input2 linker1 linker2 output1 [Net1/input1] type = FakeCluster ...
[Net1] inputClusters = input2 outputClusters = output1 spreadOrder = input2 linker1 linker2 output1 clustersList = input1 input2 output1 [input1] type = FakeCluster ...
Definition at line 209 of file neuralnet.h.
Constructor & Destructor Documentation
NeuralNet | ( | ) |
Construct an empty neural network.
Definition at line 24 of file neuralnet.cpp.
~NeuralNet | ( | ) |
Destructor.
Definition at line 28 of file neuralnet.cpp.
Member Function Documentation
void addCluster | ( | Cluster * | c, |
bool | isInput = false , |
||
bool | isOutput = false |
||
) |
Add a Cluster into the neural network
If isInput is true then the Cluster will be considered as an Input Cluster of this network
If isOutput is true then the Cluster will be considered as an Output Cluster of this network.
Definition at line 31 of file neuralnet.cpp.
References NeuralNet::clsMap, NeuralNet::clustersv, NeuralNet::find(), NeuralNet::hidclusters, NeuralNet::inclusters, Updatable::name(), and NeuralNet::outclusters.
Referenced by NeuralNet::configure().
void addInputCluster | ( | Cluster * | c | ) | [inline] |
Add a Cluster and mark it as Input
Behave exactly the same of addCluster( c, true, false )
Definition at line 232 of file neuralnet.h.
void addLinker | ( | Linker * | l | ) |
Add Linker.
Definition at line 172 of file neuralnet.cpp.
References NeuralNet::find(), Linker::from(), NeuralNet::inLinks, NeuralNet::linkersv, NeuralNet::lksMap, Updatable::name(), NeuralNet::outLinks, and Linker::to().
Referenced by NeuralNet::configure().
void addOutputCluster | ( | Cluster * | c | ) | [inline] |
Add a Cluster and mark it as Output
Behave exactly the same of addCluster( c, false, true )
Definition at line 237 of file neuralnet.h.
PointerTo byName | ( | QString | aName, |
PointerTo & | aPointer | ||
) | [inline] |
Search into the net for the presence of an Updatable with name aName; on success set the pointer aPointer and return it, otherwise it set aPointer to zero and return zero.
This allow to use it both into an if-statement and an assignment:
BiasedCluster* bias1; BiasedCluster* bias2; if ( byName("aName", bias1 ) ) { //--- ok, there is a BiasedCluster with name "aName" //--- now bias1 points to the BiasedCluster with name "aName" } else { //--- error, there is no BiasedCluster with that name //--- now bias1 is NULL } //--- you can also use it for assignment: bias2 = byName("aName", bias1);
Definition at line 308 of file neuralnet.h.
ClusterList clusters | ( | ) | const |
Returns the vector of Clusters contained.
Definition at line 156 of file neuralnet.cpp.
References NeuralNet::clustersv.
void configure | ( | ConfigurationParameters & | params, |
QString | prefix | ||
) | [virtual] |
Configures the object using a ConfigurationParameters object.
- Parameters:
-
params the configuration parameters object with parameters to use prefix the prefix to use to access the object configuration parameters. This is guaranteed to end with the separator character when called by the factory, so you don't need to add one
Implements ParameterSettableWithConfigureFunction.
Definition at line 320 of file neuralnet.cpp.
References NeuralNet::addCluster(), NeuralNet::addLinker(), ConfigurationParameters::getGroupsList(), ConfigurationParameters::getObjectFromGroup(), ConfigurationParameters::getValue(), ConfigurationParameters::GroupSeparator(), NeuralNet::markAsInput(), NeuralNet::markAsOutput(), NeuralNet::setName(), ConfigurationParameters::startRememberingGroupObjectAssociations(), ConfigurationParameters::stopRememberingGroupObjectAssociations(), and NeuralNet::ups.
void describe | ( | QString | type | ) | [static] |
Add to Factory::typeDescriptions() the descriptions of all parameters and subgroups.
Reimplemented from ParameterSettable.
Definition at line 453 of file neuralnet.cpp.
References ParameterSettable::addTypeDescription(), ParameterSettable::Descriptor::describeObject(), ParameterSettable::ObjectDescriptor::help(), ParameterSettable::IsList, ParameterSettable::IsMandatory, ParameterSettable::ObjectDescriptor::props(), and ParameterSettable::ObjectDescriptor::type().
bool find | ( | const Cluster * | cl | ) | const |
Return true if the Cluster is in this net.
Definition at line 305 of file neuralnet.cpp.
References NeuralNet::clustersv.
Referenced by NeuralNet::addCluster(), NeuralNet::addLinker(), NeuralNet::markAsInput(), NeuralNet::markAsOutput(), NeuralNet::removeCluster(), NeuralNet::removeLinker(), NeuralNet::setOrder(), and NeuralNet::unmark().
bool find | ( | const Updatable * | u | ) | const |
Return true if the Updatable object is in this net.
Definition at line 313 of file neuralnet.cpp.
References NeuralNet::clustersv, and NeuralNet::linkersv.
bool find | ( | const Linker * | l | ) | const |
Return true if the Linker is in this net.
Definition at line 309 of file neuralnet.cpp.
References NeuralNet::linkersv.
Updatable * getByName | ( | QString | name | ) |
Return the Updatable with the name specified
Returns NULL-pointer if there's no updatable object whit the name specified
- Warning:
- return the first that finds. If you have named different Updatables with same name there no way to retrieve all of them with this methods... call them with unique name ;-)
Definition at line 292 of file neuralnet.cpp.
References NeuralNet::clsMap, NeuralNet::lksMap, and NeuralNet::name().
ClusterList hiddenClusters | ( | ) | const |
Returns the vector of Hidden Clusters contained (i.e.
UnMarked Clusters)
Definition at line 168 of file neuralnet.cpp.
References NeuralNet::hidclusters.
ClusterList inputClusters | ( | ) | const |
Returns the vector of Input Clusters contained.
Definition at line 160 of file neuralnet.cpp.
References NeuralNet::inclusters.
Referenced by BackPropagationAlgo::calculateMSE(), and BackPropagationAlgo::learn().
bool isIsolated | ( | Cluster * | c | ) | const |
Return true if there isn't any Linker connected with Cluster c.
Definition at line 146 of file neuralnet.cpp.
References NeuralNet::inLinks, and NeuralNet::outLinks.
LinkerList linkers | ( | ) | const |
Returns the array of Linkers contained.
Definition at line 223 of file neuralnet.cpp.
References NeuralNet::linkersv.
LinkerList linkers | ( | Cluster * | c, |
bool | out = false |
||
) | const |
If out is true, return the Linkers outgoing from Cluster c, otherwise return incoming Linkers.
Definition at line 227 of file neuralnet.cpp.
References NeuralNet::inLinks, and NeuralNet::outLinks.
void markAsInput | ( | Cluster * | c | ) |
Mark a Cluster as an Input Cluster of this network.
Definition at line 77 of file neuralnet.cpp.
References NeuralNet::find(), NeuralNet::hidclusters, and NeuralNet::inclusters.
Referenced by NeuralNet::configure().
void markAsOutput | ( | Cluster * | c | ) |
Mark a Cluster as an Output Cluster of this network.
Definition at line 98 of file neuralnet.cpp.
References NeuralNet::find(), NeuralNet::hidclusters, and NeuralNet::outclusters.
Referenced by NeuralNet::configure().
QString name | ( | ) | [inline] |
return the name of the NeuralNet
Definition at line 223 of file neuralnet.h.
Referenced by NeuralNet::getByName().
UpdatableList order | ( | ) | const [inline] |
Return the order.
Definition at line 274 of file neuralnet.h.
ClusterList outputClusters | ( | ) | const |
Returns the vector of Output Clusters contained.
Definition at line 164 of file neuralnet.cpp.
References NeuralNet::outclusters.
Referenced by BackPropagationAlgo::calculateMSE(), BackPropagationAlgo::learn(), and BackPropagationAlgo::neuralNetChanged().
void randomize | ( | double | min, |
double | max | ||
) |
This randomize the free parameters of the all elements of the neural net
This method call randomize method of every Cluster and Linker inserted.
- Parameters:
-
min is the lower-bound of random number generator desired max is the upper-bound of random number generator desired
Definition at line 281 of file neuralnet.cpp.
References NeuralNet::clustersv, and NeuralNet::linkersv.
bool removeCluster | ( | Cluster * | c | ) |
Remove a Cluster from the network.
Definition at line 59 of file neuralnet.cpp.
References NeuralNet::clsMap, NeuralNet::clustersv, NeuralNet::find(), NeuralNet::hidclusters, NeuralNet::inclusters, Updatable::name(), and NeuralNet::outclusters.
bool removeLinker | ( | Linker * | l | ) |
Remove Linker.
Definition at line 206 of file neuralnet.cpp.
References NeuralNet::find(), Linker::from(), NeuralNet::inLinks, NeuralNet::linkersv, NeuralNet::lksMap, Updatable::name(), NeuralNet::outLinks, and Linker::to().
void save | ( | ConfigurationParameters & | params, |
QString | prefix | ||
) | [virtual] |
Save the actual status of parameters into the ConfigurationParameters object passed.
- Parameters:
-
params the configuration parameters object on which save actual parameters prefix the prefix to use to access the object configuration parameters.
Implements ParameterSettable.
Definition at line 414 of file neuralnet.cpp.
References NeuralNet::clustersv, ConfigurationParameters::createGroup(), ConfigurationParameters::createParameter(), NeuralNet::inclusters, NeuralNet::linkersv, Updatable::name(), NeuralNet::outclusters, Linker::save(), Cluster::save(), ConfigurationParameters::startObjectParameters(), and NeuralNet::ups.
Referenced by BackPropagationAlgo::save().
void setName | ( | QString | name | ) | [inline] |
Set the name of the NeuralNet It's useful when loading from ConfigurationParameters more than NeuralNet or from LearningAlgorithms subclasses.
Definition at line 219 of file neuralnet.h.
Referenced by NeuralNet::configure().
void setOrder | ( | Updatable * | updatables[], |
unsigned int | dim | ||
) |
Set the order.
Definition at line 248 of file neuralnet.cpp.
References NeuralNet::find(), and NeuralNet::ups.
void setOrder | ( | const UpdatableList & | u | ) |
Set the order.
Definition at line 264 of file neuralnet.cpp.
References NeuralNet::find(), and NeuralNet::ups.
void step | ( | ) | [inline] |
Step.
Definition at line 278 of file neuralnet.h.
Referenced by BackPropagationAlgo::calculateMSE(), and BackPropagationAlgo::learn().
void unmark | ( | Cluster * | c | ) |
Eliminate the marks from Cluster passed.
- Warning:
- if a Cluster have two marker (Input and Output marks) then both marker are removed
Definition at line 119 of file neuralnet.cpp.
References NeuralNet::find(), NeuralNet::hidclusters, NeuralNet::inclusters, and NeuralNet::outclusters.
void unmarkAll | ( | ) |
Eliminate the marks from all Cluster present in this networks.
Definition at line 139 of file neuralnet.cpp.
References NeuralNet::clustersv, NeuralNet::hidclusters, NeuralNet::inclusters, and NeuralNet::outclusters.
Member Data Documentation
ClustersMap clsMap [protected] |
map name -> Cluster*
Definition at line 364 of file neuralnet.h.
Referenced by NeuralNet::addCluster(), NeuralNet::getByName(), and NeuralNet::removeCluster().
ClusterList clustersv [protected] |
Clusters.
Definition at line 352 of file neuralnet.h.
Referenced by NeuralNet::addCluster(), NeuralNet::clusters(), NeuralNet::find(), NeuralNet::randomize(), NeuralNet::removeCluster(), NeuralNet::save(), and NeuralNet::unmarkAll().
ClusterList hidclusters [protected] |
unmarked Clusters
Definition at line 358 of file neuralnet.h.
Referenced by NeuralNet::addCluster(), NeuralNet::hiddenClusters(), NeuralNet::markAsInput(), NeuralNet::markAsOutput(), NeuralNet::removeCluster(), NeuralNet::unmark(), and NeuralNet::unmarkAll().
ClusterList inclusters [protected] |
Input Clusters.
Definition at line 354 of file neuralnet.h.
Referenced by NeuralNet::addCluster(), NeuralNet::inputClusters(), NeuralNet::markAsInput(), NeuralNet::removeCluster(), NeuralNet::save(), NeuralNet::unmark(), and NeuralNet::unmarkAll().
LinkVecMap inLinks [protected] |
mappa dei linkers entranti (cluster -> vettore linkers entranti)
Definition at line 368 of file neuralnet.h.
Referenced by NeuralNet::addLinker(), NeuralNet::isIsolated(), NeuralNet::linkers(), and NeuralNet::removeLinker().
LinkerList linkersv [protected] |
Linkers.
Definition at line 360 of file neuralnet.h.
Referenced by NeuralNet::addLinker(), NeuralNet::find(), NeuralNet::linkers(), NeuralNet::randomize(), NeuralNet::removeLinker(), and NeuralNet::save().
LinkersMap lksMap [protected] |
map name -> Linker*
Definition at line 374 of file neuralnet.h.
Referenced by NeuralNet::addLinker(), NeuralNet::getByName(), and NeuralNet::removeLinker().
QString namev [protected] |
name of this NeuralNet
Definition at line 350 of file neuralnet.h.
ClusterList outclusters [protected] |
Output Clusters.
Definition at line 356 of file neuralnet.h.
Referenced by NeuralNet::addCluster(), NeuralNet::markAsOutput(), NeuralNet::outputClusters(), NeuralNet::removeCluster(), NeuralNet::save(), NeuralNet::unmark(), and NeuralNet::unmarkAll().
LinkVecMap outLinks [protected] |
map of outgoing linkers (cluster -> vettore linkers uscenti)
Definition at line 370 of file neuralnet.h.
Referenced by NeuralNet::addLinker(), NeuralNet::isIsolated(), NeuralNet::linkers(), and NeuralNet::removeLinker().
UpdatableList ups [protected] |
Array of Updateables ordered as specified.
Definition at line 377 of file neuralnet.h.
Referenced by NeuralNet::configure(), NeuralNet::save(), and NeuralNet::setOrder().
The documentation for this class was generated from the following files:
- nnfw/include/neuralnet.h
- nnfw/src/neuralnet.cpp