The Neural Network Class. More...
Public Member Functions | |
NeuralNet () | |
Construct an empty neural network. More... | |
~NeuralNet () | |
Destructor. More... | |
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. More... | |
void | addInputCluster (Cluster *c) |
Add a Cluster and mark it as Input Behave exactly the same of addCluster( c, true, false ) More... | |
void | addLinker (Linker *l) |
Add Linker. More... | |
void | addObserver (NeuralNetObserver *observer) |
add the observer to the list of current observers More... | |
void | addOutputCluster (Cluster *c) |
Add a Cluster and mark it as Output Behave exactly the same of addCluster( c, false, true ) More... | |
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. More... | |
ClusterList | clusters () const |
Returns the vector of Clusters contained. More... | |
virtual void | configure (ConfigurationParameters ¶ms, QString prefix) |
Configures the object using a ConfigurationParameters object. More... | |
bool | find (const Cluster *) const |
Return true if the Cluster is in this net. More... | |
bool | find (const Linker *) const |
Return true if the Linker is in this net. More... | |
bool | find (const Updatable *) const |
Return true if the Updatable object is in this net. More... | |
Updatable * | getByName (QString) |
Return the Updatable with the name specified Returns NULL-pointer if there's no updatable object whit the name specified More... | |
ParameterSettableUI * | getUIManager () |
return the UI Manager for accessing to the viewers of NeuralNet More... | |
ClusterList | hiddenClusters () const |
Returns the vector of Hidden Clusters contained (i.e. More... | |
ClusterList | inputClusters () const |
Returns the vector of Input Clusters contained. More... | |
bool | isIsolated (Cluster *c) const |
Return true if there isn't any Linker connected with Cluster c. More... | |
LinkerList | linkers () const |
Returns the array of Linkers contained. More... | |
LinkerList | linkers (Cluster *c, bool out=false) const |
If out is true, return the Linkers outgoing from Cluster c, otherwise return incoming Linkers. More... | |
void | markAsInput (Cluster *c) |
Mark a Cluster as an Input Cluster of this network. More... | |
void | markAsOutput (Cluster *c) |
Mark a Cluster as an Output Cluster of this network. More... | |
QString | name () |
return the name of the NeuralNet More... | |
UpdatableList | order () const |
Return the order. More... | |
ClusterList | outputClusters () const |
Returns the vector of Output Clusters contained. More... | |
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. More... | |
bool | removeCluster (Cluster *c) |
Remove a Cluster from the network. More... | |
bool | removeLinker (Linker *) |
Remove Linker. More... | |
void | removeObserver (NeuralNetObserver *observer) |
remove the observer from the list of current observers More... | |
virtual void | save (ConfigurationParameters ¶ms, QString prefix) |
Save the actual status of parameters into the ConfigurationParameters object passed. More... | |
void | setName (QString name) |
Set the name of the NeuralNet It's useful when loading from ConfigurationParameters more than NeuralNet or from LearningAlgorithms subclasses. More... | |
void | setOrder (Updatable *updatables[], unsigned int dim) |
Set the order. More... | |
void | setOrder (const UpdatableList &) |
Set the order. More... | |
void | step () |
Step. More... | |
void | unmark (Cluster *c) |
Eliminate the marks from Cluster passed. More... | |
void | unmarkAll () |
Eliminate the marks from all Cluster present in this networks. More... | |
Public Member Functions inherited from ParameterSettable | |
void | addObserver (RuntimeParameterObserver *obs) |
T | getRuntimeParameter (QString paramName) |
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 ParameterSettable | |
static void | describe (QString type) |
static QString | fullParameterDescriptionPath (QString type, QString param) |
static QString | fullSubgroupDescriptionPath (QString type, QString sub) |
Protected Types | |
typedef QMap< QString, Cluster * > | ClustersMap |
typedef QMap< QString, Linker * > | LinkersMap |
typedef QMap< Cluster *, LinkerList > | LinkVecMap |
Protected Attributes | |
ClustersMap | clsMap |
map name -> Cluster* More... | |
ClusterList | clustersv |
Clusters. More... | |
unsigned int | dimUps |
ClusterList | hidclusters |
unmarked Clusters More... | |
ClusterList | inclusters |
Input Clusters. More... | |
LinkVecMap | inLinks |
mappa dei linkers entranti (cluster -> vettore linkers entranti) More... | |
LinkerList | linkersv |
Linkers. More... | |
LinkersMap | lksMap |
map name -> Linker* More... | |
QString | namev |
name of this NeuralNet More... | |
QList< NeuralNetObserver * > | observers |
the List of Observers More... | |
ClusterList | outclusters |
Output Clusters. More... | |
LinkVecMap | outLinks |
map of outgoing linkers (cluster -> vettore linkers uscenti) More... | |
UpdatableList | ups |
Array of Updateables ordered as specified. More... | |
Additional Inherited Members | |
Public Types inherited from ParameterSettable | |
enum | Property |
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 |
Protected Member Functions inherited from ParameterSettable | |
void | notifyChangesToParam (QString paramName) |
Static Protected Member Functions inherited from ParameterSettable | |
static Descriptor | addTypeDescription (QString type, QString shortHelp, QString longHelp=QString("")) |
static void | setGraphicalEditor (QString type) |
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
The same NeuralNet can be configured without specifing clustersList and linkersList with the following file INI:
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:
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:
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 = input2outputClusters = output1spreadOrder = input2 linker1 linker2 output1[Net1/input1]type = FakeCluster...[Net1]inputClusters = input2outputClusters = output1spreadOrder = input2 linker1 linker2 output1clustersList = input1 input2 output1[input1]type = FakeCluster...
Definition at line 221 of file neuralnet.h.
Constructor & Destructor Documentation
NeuralNet | ( | ) |
Construct an empty neural network.
Definition at line 29 of file neuralnet.cpp.
~NeuralNet | ( | ) |
Destructor.
Definition at line 33 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 53 of file neuralnet.cpp.
References NeuralNet::clsMap, NeuralNet::clustersv, NeuralNet::find(), NeuralNet::hidclusters, NeuralNet::inclusters, Updatable::name(), and NeuralNet::outclusters.
Referenced by NeuralNet::configure().
|
inline |
Add a Cluster and mark it as Input
Behave exactly the same of addCluster( c, true, false )
Definition at line 250 of file neuralnet.h.
void addLinker | ( | Linker * | l | ) |
Add Linker.
Definition at line 194 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 addObserver | ( | NeuralNetObserver * | observer | ) |
add the observer to the list of current observers
Definition at line 44 of file neuralnet.cpp.
References NeuralNet::observers.
|
inline |
Add a Cluster and mark it as Output
Behave exactly the same of addCluster( c, false, true )
Definition at line 255 of file neuralnet.h.
|
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:
Definition at line 329 of file neuralnet.h.
ClusterList clusters | ( | ) | const |
Returns the vector of Clusters contained.
Definition at line 178 of file neuralnet.cpp.
References NeuralNet::clustersv.
|
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 342 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.
|
static |
Add to Factory::typeDescriptions() the descriptions of all parameters and subgroups.
Definition at line 475 of file neuralnet.cpp.
References ParameterSettable::addTypeDescription(), ParameterSettable::IsList, and ParameterSettable::IsMandatory.
bool find | ( | const Cluster * | cl | ) | const |
Return true if the Cluster is in this net.
Definition at line 327 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 Linker * | l | ) | const |
Return true if the Linker is in this net.
Definition at line 331 of file neuralnet.cpp.
References NeuralNet::linkersv.
bool find | ( | const Updatable * | u | ) | const |
Return true if the Updatable object is in this net.
Definition at line 335 of file neuralnet.cpp.
References NeuralNet::clustersv, and 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 314 of file neuralnet.cpp.
References NeuralNet::clsMap, NeuralNet::lksMap, and NeuralNet::name().
|
virtual |
return the UI Manager for accessing to the viewers of NeuralNet
Reimplemented from ParameterSettable.
Definition at line 36 of file neuralnet.cpp.
ClusterList hiddenClusters | ( | ) | const |
Returns the vector of Hidden Clusters contained (i.e.
UnMarked Clusters)
Definition at line 190 of file neuralnet.cpp.
References NeuralNet::hidclusters.
ClusterList inputClusters | ( | ) | const |
Returns the vector of Input Clusters contained.
Definition at line 182 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 168 of file neuralnet.cpp.
References NeuralNet::inLinks, and NeuralNet::outLinks.
LinkerList linkers | ( | ) | const |
Returns the array of Linkers contained.
Definition at line 245 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 249 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 99 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 120 of file neuralnet.cpp.
References NeuralNet::find(), NeuralNet::hidclusters, and NeuralNet::outclusters.
Referenced by NeuralNet::configure().
|
inline |
return the name of the NeuralNet
Definition at line 235 of file neuralnet.h.
Referenced by NeuralNet::getByName().
|
inline |
Return the order.
Definition at line 292 of file neuralnet.h.
ClusterList outputClusters | ( | ) | const |
Returns the vector of Output Clusters contained.
Definition at line 186 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 303 of file neuralnet.cpp.
References NeuralNet::clustersv, and NeuralNet::linkersv.
bool removeCluster | ( | Cluster * | c | ) |
Remove a Cluster from the network.
Definition at line 81 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 228 of file neuralnet.cpp.
References NeuralNet::find(), Linker::from(), NeuralNet::inLinks, NeuralNet::linkersv, NeuralNet::lksMap, Updatable::name(), NeuralNet::outLinks, and Linker::to().
void removeObserver | ( | NeuralNetObserver * | observer | ) |
remove the observer from the list of current observers
Definition at line 49 of file neuralnet.cpp.
References NeuralNet::observers.
|
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 436 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().
|
inline |
Set the name of the NeuralNet It's useful when loading from ConfigurationParameters more than NeuralNet or from LearningAlgorithms subclasses.
Definition at line 231 of file neuralnet.h.
Referenced by NeuralNet::configure().
void setOrder | ( | Updatable * | updatables[], |
unsigned int | dim | ||
) |
Set the order.
Definition at line 270 of file neuralnet.cpp.
References NeuralNet::find(), and NeuralNet::ups.
void setOrder | ( | const UpdatableList & | u | ) |
Set the order.
Definition at line 286 of file neuralnet.cpp.
References NeuralNet::find(), and NeuralNet::ups.
|
inline |
Step.
Definition at line 296 of file neuralnet.h.
References NeuralNetObserver::onStepDone().
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 141 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 161 of file neuralnet.cpp.
References NeuralNet::clustersv, NeuralNet::hidclusters, NeuralNet::inclusters, and NeuralNet::outclusters.
Member Data Documentation
|
protected |
map name -> Cluster*
Definition at line 385 of file neuralnet.h.
Referenced by NeuralNet::addCluster(), NeuralNet::getByName(), and NeuralNet::removeCluster().
|
protected |
Clusters.
Definition at line 373 of file neuralnet.h.
Referenced by NeuralNet::addCluster(), NeuralNet::clusters(), NeuralNet::find(), NeuralNet::randomize(), NeuralNet::removeCluster(), NeuralNet::save(), and NeuralNet::unmarkAll().
|
protected |
unmarked Clusters
Definition at line 379 of file neuralnet.h.
Referenced by NeuralNet::addCluster(), NeuralNet::hiddenClusters(), NeuralNet::markAsInput(), NeuralNet::markAsOutput(), NeuralNet::removeCluster(), NeuralNet::unmark(), and NeuralNet::unmarkAll().
|
protected |
Input Clusters.
Definition at line 375 of file neuralnet.h.
Referenced by NeuralNet::addCluster(), NeuralNet::inputClusters(), NeuralNet::markAsInput(), NeuralNet::removeCluster(), NeuralNet::save(), NeuralNet::unmark(), and NeuralNet::unmarkAll().
|
protected |
mappa dei linkers entranti (cluster -> vettore linkers entranti)
Definition at line 389 of file neuralnet.h.
Referenced by NeuralNet::addLinker(), NeuralNet::isIsolated(), NeuralNet::linkers(), and NeuralNet::removeLinker().
|
protected |
Linkers.
Definition at line 381 of file neuralnet.h.
Referenced by NeuralNet::addLinker(), NeuralNet::find(), NeuralNet::linkers(), NeuralNet::randomize(), NeuralNet::removeLinker(), and NeuralNet::save().
|
protected |
map name -> Linker*
Definition at line 395 of file neuralnet.h.
Referenced by NeuralNet::addLinker(), NeuralNet::getByName(), and NeuralNet::removeLinker().
|
protected |
name of this NeuralNet
Definition at line 371 of file neuralnet.h.
|
protected |
the List of Observers
Definition at line 402 of file neuralnet.h.
Referenced by NeuralNet::addObserver(), and NeuralNet::removeObserver().
|
protected |
Output Clusters.
Definition at line 377 of file neuralnet.h.
Referenced by NeuralNet::addCluster(), NeuralNet::markAsOutput(), NeuralNet::outputClusters(), NeuralNet::removeCluster(), NeuralNet::save(), NeuralNet::unmark(), and NeuralNet::unmarkAll().
|
protected |
map of outgoing linkers (cluster -> vettore linkers uscenti)
Definition at line 391 of file neuralnet.h.
Referenced by NeuralNet::addLinker(), NeuralNet::isIsolated(), NeuralNet::linkers(), and NeuralNet::removeLinker().
|
protected |
Array of Updateables ordered as specified.
Definition at line 398 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