///////////////////////////////////////////////////////////////////////////// // // class LinNeuralNet // // source file // // Copyright (c) 2004 Georg Holzmann // // For information on usage and redistribution, and for a DISCLAIMER OF ALL // WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. // ///////////////////////////////////////////////////////////////////////////// #include "LinNeuralNet.h" //-------------------------------------------------- /* Constructor */ LinNeuralNet::LinNeuralNet(int netsize) : learn_rate_(0), range_(1), IW_(NULL), b1_(0) { // set random seed: srand( (unsigned)time(NULL) ); netsize_ = (netsize<1) ? 1 : netsize; } //-------------------------------------------------- /* Destructor */ LinNeuralNet::~LinNeuralNet() { if(IW_) delete[] IW_; } //-------------------------------------------------- /* creates a new IW-matrix (size: netsize_) and * b1-vector * ATTENTION: if they exist they'll be deleted */ bool LinNeuralNet::createNeurons() { // delete if they exist if(IW_) delete[] IW_; IW_ = new float[netsize_]; if(!IW_) return false; return true; } //-------------------------------------------------- /* inits the weight matrix and the bias vector of * the network with random values between [min|max] */ bool LinNeuralNet::initNetworkRand(const int &min, const int &max) { if(!IW_) return false; // make randomvalue between 0 and 1 // then map it to the bounds b1_ = ((float)rand()/(float)RAND_MAX)*(max-min) + min; for(int i=0; i