22 #include "configurationhelper.h"
25 using namespace Eigen;
29 Cluster::Cluster(
unsigned int numNeurons, QString name ) :
31 inputdata(VectorXd::Zero(numNeurons)),
32 outputdata(VectorXd::Zero(numNeurons)),
35 setDelegateFor<Cluster, &Cluster::inputs>(
"inputs" );
36 setDelegateFor<Cluster, &Cluster::outputs>(
"outputs" );
47 inputdata(VectorXd::Zero(numneurons)),
48 outputdata(VectorXd::Zero(numneurons)),
52 setDelegateFor<Cluster, &Cluster::inputs>(
"inputs" );
53 setDelegateFor<Cluster, &Cluster::outputs>(
"outputs" );
57 QString vectorSizeErrorTmpl(
"The number of elements of the %1 vector in configuration file (%1) is different from the number of neurons (%2)");
61 if ( !vect.isEmpty() && vect.size() != (int)numneurons ) {
62 qWarning() << vectorSizeErrorTmpl.arg(
"inputs" ).arg( vect.size() ).arg( numneurons );
65 inputdata = Eigen::Map<VectorXd>(vect.data(), numneurons);
70 if ( !vect.isEmpty() && vect.size() != (int)numneurons ) {
71 qWarning() << vectorSizeErrorTmpl.arg(
"outputs" ).arg( vect.size() ).arg( numneurons );
74 outputdata = Eigen::Map<VectorXd>(vect.data(), numneurons);
92 updater->setCluster(
this );
96 inputdata[neuron] = value;
104 inputdata.setConstant( value );
114 return inputdata[neuron];
118 outputdata[neuron] = value;
126 return outputdata[neuron];
133 params.
createParameter(prefix,
"numNeurons", QString::number(numneurons));
137 for (
int i = 0; i < inputdata.size(); i++) {
138 list.push_back(QString::number(inputdata[i]));
143 for (
int i = 0; i < outputdata.size(); i++) {
144 list.push_back(QString::number(outputdata[i]));
148 updater->save( params, params.
createSubGroup(prefix,
"OutFunction") );
155 d.
describeBool(
"accumulate" ).
def(
false ).
help(
"If true new inputs will be added to the previous values" );
158 d.
describeSubgroup(
"OutFunction" ).
type(
"OutputFunction" ).
help(
"The output function used to calculate the output values" );