// 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(); }
public RProp(ResponseNodeSet Master) : this(Master, 0.5, 1.2) { }
public RProp(ResponseNodeSet Master, double Down, double Up) : base(Master) { this._DownAxon = Down; this._UpAxon = Up; }
public BProp(ResponseNodeSet Master) : this(Master, 0.25, 0.025) { }
public BProp(ResponseNodeSet Master, double LearningRate, double Momentum) : base(Master) { this._LearningRate = LearningRate; this._Momentum = Momentum; }
public HProp(ResponseNodeSet Master) : base(Master) { }
public HProp(ResponseNodeSet Master, double Down, double Up) : base(Master, Down, Up) { }
public QProp(ResponseNodeSet Master, double Slope, double Acceleration, double Scale) : base(Master) { this._Slope = Slope; this._Acceleration = Acceleration; this._Scale = Scale; }
public MProp(ResponseNodeSet Master, double Gradient, double Momentum) : base(Master) { this._GradientWeight = Gradient; this._MomentumWeight = Momentum; }
public iRPropMinus(ResponseNodeSet Master) : base(Master) { }
public iRPropMinus(ResponseNodeSet Master, double Down, double Up) : base(Master, Down, Up) { }
public NeuralRule(ResponseNodeSet Master) { this._master = Master; }
public RPropPlus(ResponseNodeSet Master) : base(Master) { }
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)); }
// 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); }