Base neural layer class
This is a base neural layer class, which represents collection of neurons.
示例#1
0
        public void ShowDetails(Layer layer)
        {
            this.Show();
            this.BringToFront();

            this.m_layer = layer;

            lbType.Text = "Type: " + layer.GetType().Name;
            lbInputs.Text = "Inputs: " + layer.InputsCount;
            lbOutput.Text = "Outputs: " + layer.NeuronsCount;
            lbNeuron.Text = "Neurons: " + layer.NeuronsCount;
        }
示例#2
0
        /// <summary>
        ///   Creates a new <see cref="DeepBeliefNetwork"/>.
        /// </summary>
        /// 
        /// <param name="function">The activation function to be used in the network neurons.</param>
        /// <param name="inputsCount">The number of inputs for the network.</param>
        /// <param name="hiddenNeurons">The number of hidden neurons in each layer.</param>
        /// 
        public DeepBeliefNetwork(IStochasticFunction function, int inputsCount, params int[] hiddenNeurons)
            : base(function, inputsCount, hiddenNeurons)
        {
            machines = new List<RestrictedBoltzmannMachine>();

            // Create first layer
            machines.Add(new RestrictedBoltzmannMachine(
                hidden: new StochasticLayer(function, hiddenNeurons[0], inputsCount),
                visible: new StochasticLayer(function, inputsCount, hiddenNeurons[0]))
            );

            // Create other layers
            for (int i = 1; i < hiddenNeurons.Length; i++)
            {
                machines.Add(new RestrictedBoltzmannMachine(
                    hidden: new StochasticLayer(function, hiddenNeurons[i], hiddenNeurons[i - 1]),
                    visible: new StochasticLayer(function, hiddenNeurons[i - 1], hiddenNeurons[i])));
            }

            // Override AForge layers
            layers = new Layer[machines.Count];
            for (int i = 0; i < layers.Length; i++)
                layers[i] = machines[i].Hidden;
        }
示例#3
0
        /// <summary>
        ///   Stacks a new Boltzmann Machine at the end of this network.
        /// </summary>
        /// 
        /// <param name="network">The machine to be added to the network.</param>
        /// 
        public void Push(RestrictedBoltzmannMachine network)
        {
            int lastLayerNeurons;

            if (machines.Count > 0)
                lastLayerNeurons = machines[machines.Count - 1].Hidden.Neurons.Length;
            else lastLayerNeurons = inputsCount;

            machines.Add(network);

            // Override AForge layers
            layers = new Layer[machines.Count];
            for (int i = 0; i < layers.Length; i++)
                layers[i] = machines[i].Hidden;
        }
示例#4
0
        /// <summary>
        ///   Removes the last layer from the network.
        /// </summary>
        /// 
        public void Pop()
        {
            if (machines.Count == 0)
                return;

            machines.RemoveAt(machines.Count - 1);

            // Override AForge layers
            layers = new Layer[machines.Count];
            for (int i = 0; i < layers.Length; i++)
                layers[i] = machines[i].Hidden;
        }
示例#5
0
        /// <summary>
        ///   Inserts a new layer at the end of this network.
        /// </summary>
        /// 
        /// <param name="neurons">The number of neurons in the layer.</param>
        /// <param name="visibleFunction">The activation function which should be used by the visible neurons.</param>
        /// <param name="hiddenFunction">The activation function which should be used by the hidden neurons.</param>
        /// 
        public void Push(int neurons, IStochasticFunction visibleFunction, IStochasticFunction hiddenFunction)
        {
            int lastLayerNeurons;

            if (machines.Count > 0)
                lastLayerNeurons = machines[machines.Count - 1].Hidden.Neurons.Length;
            else lastLayerNeurons = inputsCount;

            machines.Add(new RestrictedBoltzmannMachine(
                hidden: new StochasticLayer(hiddenFunction, neurons, lastLayerNeurons),
                visible: new StochasticLayer(visibleFunction, lastLayerNeurons, neurons)));

            // Override AForge layers
            layers = new Layer[machines.Count];
            for (int i = 0; i < layers.Length; i++)
                layers[i] = machines[i].Hidden;
        }