bool Neuron::init(const UINT numInputs,const Type activationFunction,Random &random,const Float minWeightRange,const Float maxWeightRange,const Float minBiasRange,const Float maxBiasRange){ if( !validateActivationFunction(activationFunction) ){ return false; } this->numInputs = numInputs; this->activationFunction = activationFunction; weights.resize(numInputs); previousUpdate.resize(numInputs); //Randomise the weights //Note, it's better to set the random values using small weights rather than [-1.0 1.0] for(unsigned int i=0; i<numInputs; i++){ weights[i] = random.getUniform(minWeightRange,maxWeightRange); previousUpdate[i] = 0; } //Randomise the bias bias = random.getUniform(minBiasRange,maxBiasRange); previousBiasUpdate = 0; return true; }
bool Neuron::init(const UINT numInputs,const UINT activationFunction){ if( !validateActivationFunction(activationFunction) ){ return false; } this->numInputs = numInputs; this->activationFunction = activationFunction; weights.resize(numInputs); previousUpdate.resize(numInputs); //Set the random seed Random random; random.setSeed( (unsigned long long)time(NULL) ); //Randomise the weights between [-0.1 0.1] //Note, it's better to set the random values using small weights rather than [-1.0 1.0] for(unsigned int i=0; i<numInputs; i++){ weights[i] = random.getRandomNumberUniform(-0.1,0.1); previousUpdate[i] = 0; } //Randomise the bias between [-0.1 0.1] bias = random.getRandomNumberUniform(-0.1,0.1); return true; }