Ejemplo n.º 1
0
        // Constructor //
        public NeuralNetwork(string Name, NodeLinkMaster Links, NodeSet Nodes, ResponseNodeSet Responses, NeuralRule Rule, Matrix Data)
        {

            // Set values //
            this._Links = Links;
            this._Nodes = Nodes;
            this._Responses = Responses;
            this._Rule = Rule;
            this._Data = Data;
            this._name = Name;

            // Initialize //
            this.Initialize();
            
        }
Ejemplo n.º 2
0
 public RProp(ResponseNodeSet Master)
     : this(Master, 0.5, 1.2)
 {
 }
Ejemplo n.º 3
0
 public RProp(ResponseNodeSet Master, double Down, double Up)
     : base(Master)
 {
     this._DownAxon = Down;
     this._UpAxon = Up;
 }
Ejemplo n.º 4
0
 public BProp(ResponseNodeSet Master)
     : this(Master, 0.25, 0.025)
 {
 }
Ejemplo n.º 5
0
 public BProp(ResponseNodeSet Master, double LearningRate, double Momentum)
     : base(Master)
 {
     this._LearningRate = LearningRate;
     this._Momentum = Momentum;
 }
Ejemplo n.º 6
0
 public HProp(ResponseNodeSet Master)
     : base(Master)
 {
 }
Ejemplo n.º 7
0
 public HProp(ResponseNodeSet Master, double Down, double Up)
     : base(Master, Down, Up)
 {
 }
Ejemplo n.º 8
0
 public QProp(ResponseNodeSet Master, double Slope, double Acceleration, double Scale)
     : base(Master)
 {
     this._Slope = Slope;
     this._Acceleration = Acceleration;
     this._Scale = Scale;
 }
Ejemplo n.º 9
0
 public MProp(ResponseNodeSet Master, double Gradient, double Momentum)
     : base(Master)
 {
     this._GradientWeight = Gradient;
     this._MomentumWeight = Momentum;
 }
Ejemplo n.º 10
0
 public iRPropMinus(ResponseNodeSet Master)
     : base(Master)
 {
 }
Ejemplo n.º 11
0
 public iRPropMinus(ResponseNodeSet Master, double Down, double Up)
     : base(Master, Down, Up)
 {
 }
Ejemplo n.º 12
0
 public NeuralRule(ResponseNodeSet Master)
 {
     this._master = Master;
 }
Ejemplo n.º 13
0
 public RPropPlus(ResponseNodeSet Master)
     : base(Master)
 {
 }
Ejemplo n.º 14
0
        public static NeuralRule Construct(string Token, ResponseNodeSet Master)
        {

            string[] toks = Token.ToLower().Split(',',';');
            for (int i = 0; i < toks.Length; i++)
            {
                toks[i] = toks[i].Trim();
            }

            switch (toks[0])
            {

                case "bprop":
                    double bp_lr = (toks.Length < 2 ? 0.35 : double.Parse(toks[1]));
                    double bp_m = (toks.Length < 3 ? 0.035 : double.Parse(toks[2]));
                    return new BProp(Master, bp_lr, bp_m);

                case "rprop":
                    double rp0_down = (toks.Length < 2 ? 0.5 : double.Parse(toks[1]));
                    double rp0_up = (toks.Length < 3 ? 1.2 : double.Parse(toks[2]));
                    return new RProp(Master, rp0_down, rp0_up);

                case "rprop+":
                    double rp1_down = (toks.Length < 2 ? 0.5 : double.Parse(toks[1]));
                    double rp1_up = (toks.Length < 3 ? 1.2 : double.Parse(toks[2]));
                    return new RPropPlus(Master, rp1_down, rp1_up);

                case "rprop-":
                    double rp2_down = (toks.Length < 2 ? 0.5 : double.Parse(toks[1]));
                    double rp2_up = (toks.Length < 3 ? 1.2 : double.Parse(toks[2]));
                    return new RPropMinus(Master, rp2_down, rp2_up);

                case "irprop+":
                    double rp3_down = (toks.Length < 2 ? 0.5 : double.Parse(toks[1]));
                    double rp3_up = (toks.Length < 3 ? 1.2 : double.Parse(toks[2]));
                    return new iRPropPlus(Master, rp3_down, rp3_up);

                case "irprop-":
                    double rp4_down = (toks.Length < 2 ? 0.5 : double.Parse(toks[1]));
                    double rp4_up = (toks.Length < 3 ? 1.2 : double.Parse(toks[2]));
                    return new iRPropMinus(Master, rp4_down, rp4_up);

                case "mprop":
                    double mp_lr = (toks.Length < 2 ? 0.01 : double.Parse(toks[1]));
                    double mp_m = (toks.Length < 3 ? 0.001 : double.Parse(toks[2]));
                    return new MProp(Master, mp_lr, mp_m);

                case "qprop":
                    return new QProp(Master);

                case "hprop":
                    double hp_down = (toks.Length < 2 ? 0.5 : double.Parse(toks[1]));
                    double hp_up = (toks.Length < 3 ? 1.2 : double.Parse(toks[2]));
                    return new HProp(Master, hp_down, hp_up);

            }

            throw new ArgumentException(string.Format("Rule '{0}' is invalid", Token));

        }
Ejemplo n.º 15
0
        // Render the network //
        public NeuralNetwork Construct()
        {

            // Create the scrubber //
            NeuralDataFactory scrubber = new NeuralDataFactory(this._SourceData, this._XValues, this._YValues, this._Where);

            // Create the data layer //
            this._DataLayer = new NN_Layer(this._DataBias, scrubber.InputKey, scrubber.Columns);

            // Create the prediction layer //
            this._PredictionLayer = new NN_Layer(this._PredictionReducer, this._PredictionActivation, scrubber.OutputKey);

            // Link predictions to last hidden //
            if (this._HiddenLayers.Count == 0)
            {
                NN_Layer.LinkChildren(this._Links, this._PredictionLayer, this._DataLayer);
            }
            else
            {

                // Data -> First.Hidden
                NN_Layer.LinkChildren(this._Links, this._HiddenLayers.First(), this._DataLayer);

                // Last.Hidden -> Predictions //
                NN_Layer.LinkChildren(this._Links, this._PredictionLayer, this._HiddenLayers.Last());

                // Hidden -> Hidden //
                for (int i = 0; i < this._HiddenLayers.Count - 1; i++)
                    NN_Layer.LinkChildren(this._Links, this._HiddenLayers[i + 1], this._HiddenLayers[i]);

            }

            // Build a nodeset //
            NodeSet nodes = new NodeSet(this._Links);

            // Build a response set //
            ResponseNodeSet responses = new ResponseNodeSet(this._Links);

            // Neural rule //
            NeuralRule rule = RuleFactory.Construct(this.DefaultRule, responses);

            // Construct //
            return new NeuralNetwork(this._name, this._Links, nodes, responses, rule, scrubber.ScrubbedData);

        }