Ejemplo n.º 1
0
        internal void SetContext(NeuronNetworkContext context)
        {
            this.networkCtx = context;

            this.outputNeuron.NetworkContext = context;
            for (var i = 0; i < this.hiddenNeuronsNo; i++)
            {
                this.hiddenNeurons[i].NetworkContext = context;
            }
        }
Ejemplo n.º 2
0
        public static NeuronNetwork Load(Stream stream, NeuronNetworkContext context)
        {
            var formatter = new SoapFormatter();
            var version   = (int)formatter.Deserialize(stream);

            if (version != Version)
            {
                throw new InvalidOperationException("Invalid version.");
            }

            var network = (NeuronNetwork)formatter.Deserialize(stream);

            network.SetContext(context);

            return(network);
        }
Ejemplo n.º 3
0
        public NeuronNetwork(int inputsNo, int hiddenNeuronsNo, NeuronNetworkContext context)
        {
            if (inputsNo <= 0)
            {
                throw new ArgumentOutOfRangeException("inputsNo", inputsNo, "The value should be greater than 0");
            }

            if (hiddenNeuronsNo <= 0)
            {
                throw new ArgumentOutOfRangeException("hiddenNeuronsNo", inputsNo, "The value should be greater than 0");
            }

            this.inputsNo        = inputsNo;
            this.hiddenNeuronsNo = hiddenNeuronsNo;
            this.hiddenNeurons   = new Neuron[hiddenNeuronsNo];
            this.outputNeuron    = new Neuron(hiddenNeuronsNo);

            for (var i = 0; i < this.hiddenNeuronsNo; i++)
            {
                this.hiddenNeurons[i] = new Neuron(inputsNo);
            }

            this.SetContext(context);
        }