Beispiel #1
0
        public void FunctionTest()
        {
            Sigmoid dense = new Sigmoid(3.6, 1);
            SparseSigmoid target = new SparseSigmoid(3.6, 1);

            double[] sx = { 1, -0.555556, 2, +0.250000, 3, -0.864407, 4, -0.916667 };
            double[] sy = { 1, -0.666667, 2, -0.166667, 3, -0.864407, 4, -0.916667 };
            double[] sz = { 1, -0.944444, 3, -0.898305, 4, -0.916667 };

            double[] dx = { -0.555556, +0.250000, -0.864407, -0.916667 };
            double[] dy = { -0.666667, -0.166667, -0.864407, -0.916667 };
            double[] dz = { -0.944444, +0.000000, -0.898305, -0.916667 };

            double expected, actual;

            expected = dense.Function(dx, dy);
            actual = target.Function(sx, sy);
            Assert.AreEqual(expected, actual);

            expected = dense.Function(dx, dz);
            actual = target.Function(sx, sz);
            Assert.AreEqual(expected, actual);

            expected = dense.Function(dy, dz);
            actual = target.Function(sy, sz);
            Assert.AreEqual(expected, actual);
        }
Beispiel #2
0
        private IKernel getKernel()
        {
            IKernel kernel;
            if (rbGaussian.Checked)
            {
                kernel = new Gaussian((double)numSigma.Value);
            }
            else if (rbPolynomial.Checked)
            {
                kernel = new Polynomial((int)numDegree.Value, (double)numSigAlpha.Value);
            }
            else if (rbLaplacian.Checked)
            {
                kernel = new Laplacian((double)numLaplacianSigma.Value);
            }
            else if (rbSigmoid.Checked)
            {
                kernel = new Sigmoid((double)numSigAlpha.Value, (double)numSigB.Value);
            }
            else throw new Exception();

            return kernel;
        }