void LinearComboFunction::configure(ConfigurationParameters& params, QString prefix) { // We don't need configured component functions here (and they will be // configured after exiting from this function) first.reset(params.getObjectFromParameter<OutputFunction>(prefix + "first", false, false)); w1 = 0.0; QString str = params.getValue(prefix + "w1"); if (!str.isNull()) { bool ok; w1 = str.toDouble(&ok); if (!ok) { w1 = 0.0; } } second.reset(params.getObjectFromParameter<OutputFunction>(prefix + "second", false, false)); w2 = 0.0; str = params.getValue(prefix + "w2"); if (!str.isNull()) { bool ok; w2 = str.toDouble(&ok); if (!ok) { w2 = 0.0; } } // We don't need to reload a reference to the cluster as he calls our setCluster // function after our creation }
void StepFunction::configure(ConfigurationParameters& params, QString prefix) { min = 0.0; QString str = params.getValue(prefix + "min"); if (!str.isNull()) { bool ok; min = str.toDouble(&ok); if (!ok) { min = 0.0; } } max = 1.0; str = params.getValue(prefix + "max"); if (!str.isNull()) { bool ok; max = str.toDouble(&ok); if (!ok) { max = 1.0; } } threshold = 0.0; str = params.getValue(prefix + "threshold"); if (!str.isNull()) { bool ok; threshold = str.toDouble(&ok); if (!ok) { threshold = 0.0; } } }
void LeakyIntegratorFunction::configure(ConfigurationParameters& params, QString prefix) { // Delta is a vector, that is a list of space-separated values QString str = params.getValue(prefix + "delta"); if (!str.isNull()) { QStringList list = str.split(QRegExp("\\s+"), QString::SkipEmptyParts); delta.resize(list.size()); for( int i = 0; i < list.size(); i++) { bool ok; delta[i] = list[i].toDouble(&ok); if (!ok) { delta[i] = 0.0; } } } // Also reloading outprev (resizing it to match delta length) str = params.getValue(prefix + "outprev"); if (!str.isNull()) { QStringList list = str.split(QRegExp("\\s+"), QString::SkipEmptyParts); outprev.resize(list.size()); for( int i = 0; i < list.size(); i++) { bool ok; outprev[i] = list[i].toDouble(&ok); if (!ok) { outprev[i] = 0.0; } } } outprev.resize(delta.size()); }
void ScaledSigmoidFunction::configure(ConfigurationParameters& params, QString prefix) { lambda = 1.0; QString str = params.getValue(prefix + "lambda"); if (!str.isNull()) { bool ok; lambda = str.toDouble(&ok); if (!ok) { lambda = 1.0; } } min = -1.0; str = params.getValue(prefix + "min"); if (!str.isNull()) { bool ok; min = str.toDouble(&ok); if (!ok) { min = -1.0; } } max = 1.0; str = params.getValue(prefix + "max"); if (!str.isNull()) { bool ok; max = str.toDouble(&ok); if (!ok) { max = 1.0; } } }
void Pattern::configure(ConfigurationParameters& params, QString prefix) { //--- get all parameters with the prefix 'cluster:' QStringList clusterList = params.getParametersWithPrefixList( prefix, "cluster:" ); foreach( QString cluster, clusterList ) { QString id = cluster.split(':')[1]; if ( id.isNull() || id.isEmpty() ) continue; //--- now, it check if there is a inputs and outputs parameter and load it QString str = params.getValue( prefix + "inputs:" + id ); DoubleVector inputs; if (!str.isNull()) { QStringList list = str.split(QRegExp("\\s+"), QString::SkipEmptyParts); for( int i=0; i<list.size(); i++) { inputs.append( list[i].toDouble() ); } } str = params.getValue( prefix + "outputs:" + id ); DoubleVector outputs; if (!str.isNull()) { QStringList list = str.split(QRegExp("\\s+"), QString::SkipEmptyParts); for( int i=0; i<list.size(); i++) { outputs.append( list[i].toDouble() ); } } if ( inputs.size() == 0 && outputs.size() == 0 ) continue; Cluster* cl = params.getObjectFromParameter<Cluster>( prefix+cluster, false, true ); if ( inputs.size() > 0 ) { setInputsOf( cl, inputs ); } if ( outputs.size() > 0 ) { setOutputsOf( cl, outputs ); } }
MatrixLinker::MatrixLinker( ConfigurationParameters& params, QString prefix ) : Linker( params, prefix ), nrows(from()->numNeurons()), ncols(to()->numNeurons()), w(nrows, ncols, true) { // the weights are read from a single vector of data supposing they are row-major arranged QString str = params.getValue(prefix + "weights"); if (!str.isNull()) { QStringList list = str.split(QRegExp("\\s+"), QString::SkipEmptyParts); int cycleLength = nrows*ncols; if (list.size() != cycleLength) { #ifdef NNFW_DEBUG qWarning() << "The number of elements of the weights in configuration file (" << list.size() << ") is different from the total number of weights (" << cycleLength << ")."; #endif cycleLength = std::min(list.size(), cycleLength); } for( int i=0; i<cycleLength; i++) { bool ok; unsigned int r = i/ncols; //--- division may be expensive unsigned int c = i%ncols; //--- module may be expensive w[r][c] = list[i].toDouble(&ok); if (!ok) { w[r][c] = 0.0; } } } }
void RampFunction::configure(ConfigurationParameters& params, QString prefix) { min_x = 0.0; QString str = params.getValue(prefix + "minX"); if (!str.isNull()) { bool ok; min_x = str.toDouble(&ok); if (!ok) { min_x = 0.0; } } max_x = 0.0; str = params.getValue(prefix + "maxX"); if (!str.isNull()) { bool ok; max_x = str.toDouble(&ok); if (!ok) { max_x = 0.0; } } min_y = 0.0; str = params.getValue(prefix + "minY"); if (!str.isNull()) { bool ok; min_y = str.toDouble(&ok); if (!ok) { min_y = 0.0; } } max_y = 0.0; str = params.getValue(prefix + "maxY"); if (!str.isNull()) { bool ok; max_y = str.toDouble(&ok); if (!ok) { max_y = 0.0; } } }
void ScaleFunction::configure(ConfigurationParameters& params, QString prefix) { rate = 1.0; QString str = params.getValue(prefix + "rate"); if (!str.isNull()) { bool ok; rate = str.toDouble(&ok); if (!ok) { rate = 1.0; } } }
void FakeSigmoidFunction::configure(ConfigurationParameters& params, QString prefix) { lambda = 1.0; QString str = params.getValue(prefix + "lambda"); if (!str.isNull()) { bool ok; lambda = str.toDouble(&ok); if (!ok) { lambda = 1.0; } } }
void GainFunction::configure(ConfigurationParameters& params, QString prefix) { gainv = 1.0; QString str = params.getValue(prefix + "gain"); if (!str.isNull()) { bool ok; gainv = str.toDouble(&ok); if (!ok) { gainv = 1.0; } } }
void LogLikeFunction::configure(ConfigurationParameters& params, QString prefix) { A = 1.0; QString str = params.getValue(prefix + "A"); if (!str.isNull()) { bool ok; A = str.toDouble(&ok); if (!ok) { A = 1.0; } } B = 5.0; str = params.getValue(prefix + "B"); if (!str.isNull()) { bool ok; B = str.toDouble(&ok); if (!ok) { B = 5.0; } } }
void LinearFunction::configure(ConfigurationParameters& params, QString prefix) { m = 0.0; QString str = params.getValue(prefix + "m"); if (!str.isNull()) { bool ok; m = str.toDouble(&ok); if (!ok) { m = 0.0; } } b = 0.0; str = params.getValue(prefix + "b"); if (!str.isNull()) { bool ok; b = str.toDouble(&ok); if (!ok) { b = 0.0; } } }
void Genotype::configure( ConfigurationParameters& params, QString prefix ) { int newsize = params.getValue( prefix + QString( "bitsize" ) ).toInt(); Q_ASSERT_X( newsize > 0, "Genotype::configure", "The bitsize must be present in the config file and its value must be greater than zero" ); resize( newsize ); QString zipdata = params.getValue( prefix + QString( "data" ) ); if ( !zipdata.isNull() ) { fromCompressedString( zipdata ); } QStringList valuesList = params.getValue( prefix + QString( "fitness" ) ) .split( QRegExp("\\s+"), QString::SkipEmptyParts ); if ( valuesList.size() > 0 ) { // read the values of fitness fitnessv.resize(0); foreach( QString avalue, valuesList ) { fitnessv << avalue.toDouble(); } // safe check if ( fitnessv.size() == 0 ) { fitnessv.append( 0 ); } }
CopyLinker::CopyLinker( ConfigurationParameters& params, QString prefix ) : Linker( params, prefix ), dataFrom(), dataTo() { dimData = qMin( to()->numNeurons(), from()->numNeurons() ); this->mode = (CopyMode)-1; //--- default initialisation, in the case the user forget to set the parameter setMode( Out2In ); QString str = params.getValue(prefix + "mode"); if ( !str.isNull() ) { str = str.toLower(); if ( str == "in2in" ) { setMode( In2In ); } else if ( str == "in2ou" ) { setMode( In2Out ); } else if ( str == "out2in" ) { setMode( Out2In ); } else if ( str == "out2out" ) { setMode( Out2Out ); } } }
void DeterministicRank::configure( ConfigurationParameters& params, QString prefix ) { nTruncation = params.getValue( prefix + QString( "nTruncation" ) ).toInt(); }