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 Linker *) const |
Return true if the Linker is in this net. | |
bool | find (const Updatable *) const |
Return true if the Updatable object 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 (Updatable *updatables[], unsigned int dim) |
Set the order. | |
void | setOrder (const UpdatableList &) |
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. | |
![]() | |
void | addObserver (RuntimeParameterObserver *obs) |
T | getRuntimeParameter (QString paramName) |
virtual ParameterSettableUI * | getUIManager () |
ParameterSettable () | |
virtual void | postConfigureInitialization () |
void | removeObserver (RuntimeParameterObserver *obs) |
void | setRuntimeParameter (QString paramName, T newvalue) |
QString | typeName () const |
![]() | |
void | addObserver (RuntimeParameterObserver *obs) |
T | getRuntimeParameter (QString paramName) |
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. | |
![]() | |
static void | describe (QString type) |
static QString | fullParameterDescriptionPath (QString type, QString param) |
static QString | fullSubgroupDescriptionPath (QString type, QString sub) |
![]() | |
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* | |
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. | |
Additional Inherited Members | |
![]() | |
enum | Property |
![]() | |
AllowMultiple | |
Default | |
IsList | |
IsMandatory | |
![]() | |
static const double | Infinity |
static const int | MaxInteger |
static const int | MinInteger |
![]() | |
void | notifyChangesToParam (QString paramName) |
![]() | |
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 209 of file neuralnet.h.
Constructor & Destructor Documentation
NeuralNet | ( | ) |
Construct an empty neural network.
Definition at line 25 of file neuralnet.cpp.
~NeuralNet | ( | ) |
Destructor.
Definition at line 29 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 32 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 232 of file neuralnet.h.
void addLinker | ( | Linker * | l | ) |
Add Linker.
Definition at line 173 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().
|
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.
|
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 308 of file neuralnet.h.
ClusterList clusters | ( | ) | const |
Returns the vector of Clusters contained.
Definition at line 157 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 321 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 454 of file neuralnet.cpp.
References ParameterSettableWithConfigureFunction::addTypeDescription(), ParameterSettable::Descriptor::describeObject(), ParameterSettable::ObjectDescriptor::help(), ParameterSettableWithConfigureFunction::IsList, ParameterSettableWithConfigureFunction::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 306 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 310 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 314 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 293 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 169 of file neuralnet.cpp.
References NeuralNet::hidclusters.
ClusterList inputClusters | ( | ) | const |
Returns the vector of Input Clusters contained.
Definition at line 161 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 147 of file neuralnet.cpp.
References NeuralNet::inLinks, and NeuralNet::outLinks.
LinkerList linkers | ( | ) | const |
Returns the array of Linkers contained.
Definition at line 224 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 228 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 78 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 99 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 223 of file neuralnet.h.
Referenced by NeuralNet::getByName().
|
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 165 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 282 of file neuralnet.cpp.
References NeuralNet::clustersv, and NeuralNet::linkersv.
bool removeCluster | ( | Cluster * | c | ) |
Remove a Cluster from the network.
Definition at line 60 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 207 of file neuralnet.cpp.
References NeuralNet::find(), Linker::from(), NeuralNet::inLinks, NeuralNet::linkersv, NeuralNet::lksMap, Updatable::name(), NeuralNet::outLinks, and Linker::to().
|
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 ParameterSettableWithConfigureFunction.
Definition at line 415 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 219 of file neuralnet.h.
Referenced by NeuralNet::configure().
void setOrder | ( | Updatable * | updatables[], |
unsigned int | dim | ||
) |
Set the order.
Definition at line 249 of file neuralnet.cpp.
References NeuralNet::find(), and NeuralNet::ups.
void setOrder | ( | const UpdatableList & | u | ) |
Set the order.
Definition at line 265 of file neuralnet.cpp.
References NeuralNet::find(), and NeuralNet::ups.
|
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 120 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 140 of file neuralnet.cpp.
References NeuralNet::clustersv, NeuralNet::hidclusters, NeuralNet::inclusters, and NeuralNet::outclusters.
Member Data Documentation
|
protected |
map name -> Cluster*
Definition at line 364 of file neuralnet.h.
Referenced by NeuralNet::addCluster(), NeuralNet::getByName(), and NeuralNet::removeCluster().
|
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().
|
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().
|
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().
|
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().
|
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().
|
protected |
map name -> Linker*
Definition at line 374 of file neuralnet.h.
Referenced by NeuralNet::addLinker(), NeuralNet::getByName(), and NeuralNet::removeLinker().
|
protected |
name of this NeuralNet
Definition at line 350 of file neuralnet.h.
|
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().
|
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().
|
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