private void Recall(bool reconstruct)
        {
            string[] sp = textBox1.Text.Split(',');
            if (sp.Length != 2)
            {
                label1.Text = "You need to enter <neuron>,<layer>!";
                label1.Refresh();
                return;
            }
            try
            {
                int    neuron = int.Parse(sp[0]);
                int    layer  = int.Parse(sp[1]);
                string c      = (layer == LAYERS.Length - 1) ? listBox1.Items[neuron].ToString() : "(not a category)";

                double[] a = (reconstruct) ? new double[LAYERS[layer]] : new double[NUM_CATEGORIES];
                a[neuron] = 1;

                double[] r = (reconstruct) ? _network.Reconstruct(a, layer) : _network.GenerateInput(a);
                Bitmap   bm;
                _atoi.Convert(r, out bm);

                label1.Text = "Reconstructing " + c + ", length of reconstruction: " + r.Length;
                label1.Refresh();

                pictureBox1.Image = bm;
                pictureBox1.Refresh();
            }
            catch (Exception ex)
            {
                label1.Text  = ex.Message + "\n" + ex.StackTrace + "\n";
                label1.Text += "Reconstruction input params invalid. neuron should be < size of layer.";
                label1.Refresh();
            }
        }
        public void Compute()
        {
            if (!CanCompute)
            {
                return;
            }

            double[]          input    = UserInput;
            DeepBeliefNetwork network  = Main.Network;
            IDatabase         database = Main.Database;

            database.Normalize(input);

            {
                double[] output         = network.GenerateOutput(input);
                double[] reconstruction = network.Reconstruct(output);
                NetworkOutput = (database.ToBitmap(reconstruction).ToBitmapImage());
            }

            if (Main.CanClassify)
            {
                double[] output = network.Compute(input);
                int      imax; output.Max(out imax);
                Classification = imax;
            }
        }
Пример #3
0
        /// <summary>
        ///   Computes the reconstruction error for
        ///   a given set of input values.
        /// </summary>
        ///
        /// <param name="inputs">The input values.</param>
        ///
        /// <returns>The squared reconstruction error.</returns>
        ///
        public double ComputeError(double[][] inputs)
        {
            double error = 0;

            for (int i = 0; i < inputs.Length; i++)
            {
                double[] output      = network.Compute(inputs[i]);
                double[] reconstruct = network.Reconstruct(output);

                for (int j = 0; j < inputs[i].Length; j++)
                {
                    double e = reconstruct[j] - inputs[i][j];
                    error += e * e;
                }
            }
            return(error);
        }
Пример #4
0
        /// <summary>
        /// Implementation of the divergence operation.
        /// </summary>
        protected override void diverge()
        {
            //convert all the modalities in a single vector
            double[] realSignal; double[] predictedSignal;
            getConcatenatedModalities(out realSignal, out predictedSignal);

            //Generate the prediction
            double[] output            = network.GenerateOutput(realSignal, 0);
            double[] networkPrediction = network.Reconstruct(output);

            //Distribute it over the Signal
            setConcatenatedModalities(null, networkPrediction);

            //Proceed to learning
            if (!learningLocked && learningRate > 0)
            {
                //teacher.Run(realSignal);
                //network.UpdateVisibleWeights();
            }
        }