Example #1
0
        /*public vNeuron(main.Network inNet, List<List<int>> inInputNs, int inLayer, int inDim)
         * {
         *  this.inputNeurons = inInputNs;
         *  this.layer = inLayer;
         *  this.dimension = inDim;
         *
         *  this.weights = new List<List<double>>();
         *  for(int i = 0; i < inNet.NUM_DEPTH; i++)
         *  {
         *      this.weights.Add(Enumerable.Repeat(DEFAULT_WEIGHT, inDim).ToList());
         *  }
         * }*/

        //Input Neuron Constructor
        public vNeuron(List <double> output)
        {
            this.layer     = 0;
            this.actFunc   = actFuncType.identity;
            this.dimension = output.Count;

            this.inputs.Add(new List <double>());
            for (int i = 0; i < this.dimension; i++)
            {
                this.inputs[0].Add(output[i]);
                this.beta.Add(0d);
            }

            this.weights.Add(MyMath.makeIdentityMatrix(this.dimension));
        }
Example #2
0
        //Hidden and Output Neuron Constructor
        public vNeuron(int layer, actFuncType func, List <List <int> > inputNeu, double weightVar, /*List<List<double>> weights, */ List <double> beta)
        {
            this.layer     = layer;
            this.actFunc   = func;
            this.dimension = beta.Count;

            foreach (List <int> vec in inputNeu)
            {
                List <int> curVec = new List <int>();
                foreach (int i in vec)
                {
                    curVec.Add(i);
                }
                this.inputNeurons.Add(curVec);
            }

            Random rng = main.rng;

            for (int k = 0; k < inputNeu.Count; k++)
            {
                this.weights.Add(new List <List <double> >());
                for (int i = 0; i < this.dimension; i++)
                {
                    this.weights[k].Add(new List <double>());
                    for (int j = 0; j < this.dimension; j++)
                    {
                        this.weights[k][i].Add(weightVar * rng.NextDouble());
                    }
                }
            }

            foreach (double x in beta)
            {
                this.beta.Add(x);
            }

            for (int j = 0; j < inputNeu.Count; j++)
            {
                //this.handedDownDelta.Add(new List<double>());
                for (int i = 0; i < beta.Count; i++)
                {
                    //this.handedDownDelta[j].Add(0d);
                }
            }
        }
Example #3
0
        //Custom Hidden and Output Neurons
        public vNeuron(int layer, actFuncType func, List <List <int> > inputNeu, List <List <List <double> > > weights, List <double> beta)
        {
            this.layer     = layer;
            this.actFunc   = func;
            this.dimension = beta.Count;

            foreach (List <int> vec in inputNeu)
            {
                List <int> curVec = new List <int>();
                foreach (int i in vec)
                {
                    curVec.Add(i);
                }
                this.inputNeurons.Add(curVec);
            }

            //Random rng = new Random();

            for (int k = 0; k < weights.Count; k++)
            {
                this.weights.Add(new List <List <double> >());
                for (int i = 0; i < weights[0].Count; i++)
                {
                    this.weights[k].Add(new List <double>());
                    for (int j = 0; j < weights[0][0].Count; j++)
                    {
                        this.weights[k][i].Add(weights[k][i][j]);
                    }
                }
            }

            foreach (double x in beta)
            {
                this.beta.Add(x);
            }

            for (int j = 0; j < inputNeu.Count; j++)
            {
                //this.handedDownDelta.Add(new List<double>());
                for (int i = 0; i < beta.Count; i++)
                {
                    //this.handedDownDelta[j].Add(0d);
                }
            }
        }
Example #4
0
        //Input Neuron Constructor
        public mNeuron(List <List <double> > output)
        {
            this.layer   = 0;
            this.actFunc = actFuncType.identity;
            int d = 0;

            this.inputs.Add(new List <List <double> >());
            for (int i = 0; i < output.Count; i++)
            {
                d++;
                this.inputs[0].Add(new List <double>());
                this.beta.Add(new List <double>());
                for (int j = 0; j < output[0].Count; j++)
                {
                    this.inputs[0][i].Add(output[i][j]);
                    this.beta[i].Add(0d);
                }
            }

            this.weights.Add(MyMath.makeIdentityMatrix(d));
        }
Example #5
0
        //Hidden and Output Neuron Constructor
        public mNeuron(int layer, int depth, actFuncType func, List <List <int> > inputNeu, double weightVar, double betaVar, int mCount, int nCount)
        {
            this.layer   = layer;
            this.depth   = depth;
            this.actFunc = func;

            foreach (List <int> vec in inputNeu)
            {
                List <int> curVec = new List <int>();
                foreach (int i in vec)
                {
                    curVec.Add(i);
                }
                this.inputNeurons.Add(curVec);
            }

            Random rng = main.rng;

            for (int k = 0; k < inputNeu.Count; k++)
            {
                this.weights.Add(new List <List <double> >());
                for (int i = 0; i < mCount; i++)
                {
                    this.weights[k].Add(new List <double>());
                    for (int j = 0; j < mCount; j++)
                    {
                        this.weights[k][i].Add(weightVar * rng.NextDouble());
                    }
                }
            }

            for (int i = 0; i < mCount; i++)
            {
                this.beta.Add(new List <double>());
                for (int j = 0; j < nCount; j++)
                {
                    this.beta[i].Add(betaVar);
                }
            }
        }
Example #6
0
        //Hidden and Output Neuron Constructor
        public Neuron(int layer, actFuncType func, List <List <int> > inputNeu, List <double> weights, double beta)
        {
            this.layer   = layer;
            this.actFunc = func;

            //this.inputNeurons = inputNeu;
            foreach (List <int> vec in inputNeu)
            {
                List <int> curVec = new List <int>();
                foreach (int i in vec)
                {
                    curVec.Add(i);
                }
                this.inputNeurons.Add(curVec);
            }

            //this.weights = weights;
            foreach (double w in weights)
            {
                this.weights.Add(w);
            }

            this.beta = beta;
        }
Example #7
0
 public void setActFunc(actFuncType x)
 {
     this.actFunc = x;
 }