예제 #1
0
        public void Init(double[] stateAv, double[] stateStddev, double[] actionMin, int vsize)
        {
            int stateDim = stateAv.GetLength(0);
            int actionDim = actionMin.GetLength(0);

            #region budowa sieci neuronowej

            V = new MLPerceptron2();
            V.Build(stateDim, CellType.Arcustangent, new int[] { vsize, 1 });
            V.SetInputDescription(new Vector(stateAv), new Vector(stateStddev));
            V.InitWeights(1.0 / Math.Sqrt(vsize + 1));
            Vval = new Vector(1);
            Vgrad = new Vector(1);

            #endregion koniec budowy sieci neuronowej

            Actions = new Vector[HORIZON_SIZE];
            NextStates = new Vector[HORIZON_SIZE];
            for (int i = 0; i < HORIZON_SIZE; i++)
            {
                Actions[i] = new Vector(actionDim, _model.GenerateControlVariables()[0]);
                NextStates[i] = new Vector(stateDim, 0.0);
            }
        }
예제 #2
0
 // umozliwia dzialanie kilku sieci (np. w roznych watkach) z tymi samymi wagami
 public void Connect2Weights(MLPerceptron2 network)
 {
     if (Layer.Length != network.Layer.Length)
         throw new Exception(this.GetType().ToString() + ".Weights2");
     for (int l = 0; l < Layer.Length; l++)
         if (Layer[l].Weights.Height != network.Layer[l].Weights.Height
             || Layer[l].Weights.Width != network.Layer[l].Weights.Width)
             throw new Exception(this.GetType().ToString() + ".Connect2Weights");
     for (int l = 0; l < Layer.Length; l++)
         Layer[l].Weights = network.Layer[l].Weights;
 }