Beispiel #1
0
        /// <summary>
        ///     Construct a deep belief neural network.
        /// </summary>
        /// <param name="inputCount">The input count.</param>
        /// <param name="hidden">The counts for the hidden layers.</param>
        /// <param name="outputCount">The output neuron count.</param>
        public DeepBeliefNetwork(int inputCount, int[] hidden, int outputCount)
        {
            int inputSize;

            _layers = new HiddenLayer[hidden.Length];
            _rbm = new RestrictedBoltzmannMachine[hidden.Length];

            for (var i = 0; i < _rbm.Length; i++)
            {
                if (i == 0)
                {
                    inputSize = inputCount;
                }
                else
                {
                    inputSize = hidden[i - 1];
                }

                _layers[i] = new HiddenLayer(this, inputSize, hidden[i]);

                _rbm[i] = new RestrictedBoltzmannMachine(_layers[i]);
            }

            _outputLayer = new DeepLayer(this, hidden[_layers.Length - 1], outputCount);
            Random = new MersenneTwisterGenerateRandom();
        }
        /// <summary>
        ///     Construct a deep belief neural network.
        /// </summary>
        /// <param name="inputCount">The input count.</param>
        /// <param name="hidden">The counts for the hidden layers.</param>
        /// <param name="outputCount">The output neuron count.</param>
        public DeepBeliefNetwork(int inputCount, int[] hidden, int outputCount)
        {
            int inputSize;

            _layers = new HiddenLayer[hidden.Length];
            _rbm    = new RestrictedBoltzmannMachine[hidden.Length];

            for (var i = 0; i < _rbm.Length; i++)
            {
                if (i == 0)
                {
                    inputSize = inputCount;
                }
                else
                {
                    inputSize = hidden[i - 1];
                }

                _layers[i] = new HiddenLayer(this, inputSize, hidden[i]);

                _rbm[i] = new RestrictedBoltzmannMachine(_layers[i]);
            }

            _outputLayer = new DeepLayer(this, hidden[_layers.Length - 1], outputCount);
            Random       = new MersenneTwisterGenerateRandom();
        }
 /// <summary>
 /// Construct restricted Boltzmann machine. 
 /// </summary>
 /// <param name="theLayer">The layer that this RBM works with.</param>
 public RestrictedBoltzmannMachine(HiddenLayer theLayer)
 {
     _layer = theLayer;
     _owner = theLayer.Owner;
     _hBias = _layer.Bias;
     _vBias = new double[VisibleCount];
 }
 /// <summary>
 ///     Construct restricted Boltzmann machine.
 /// </summary>
 /// <param name="theLayer">The layer that this RBM works with.</param>
 public RestrictedBoltzmannMachine(HiddenLayer theLayer)
 {
     _layer = theLayer;
     _owner = theLayer.Owner;
     _hBias = _layer.Bias;
     _vBias = new double[VisibleCount];
 }
Beispiel #5
0
        /// <summary>
        /// Randomize the weights of the neural network.
        /// </summary>
        public void Reset()
        {
            for (int i = 0; i < _rbm.Length; i++)
            {
                HiddenLayer layer = _layers[i];

                double a = 1.0 / layer.InputCount;

                for (int j = 0; j < layer.OutputCount; j++)
                {
                    for (int k = 0; k < layer.InputCount; k++)
                    {
                        layer.Weights[j][k] = Random.NextDouble(-a, a);
                    }
                }
            }
        }