Example #1
0
            internal static void LinkChildren(NodeLinkMaster Master, NN_Layer TopLayer, NN_Layer BottomLayer)
            {

                foreach (NeuralNode n in TopLayer._Nodes)
                {
                    if (n.Affinity != NeuralNodeAffinity.Static)
                        n.LinkChildren(Master, BottomLayer._Nodes);
                }

            }
Example #2
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);

        }