Exemplo n.º 1
0
        private double[] gradient(double[] w)
        {
            double[] y = Outputs;
            double   p = Epsilon;

            sizeI = 0;
            for (int i = 0; i < y.Length; i++)
            {
                double d = z[i] - y[i];

                // generate index set I
                if (d < -p)
                {
                    z[sizeI] = C[i] * (d + p);
                    I[sizeI] = i;
                    sizeI++;
                }
                else if (d > p)
                {
                    z[sizeI] = C[i] * (d - p);
                    I[sizeI] = i;
                    sizeI++;
                }
            }

            LinearNewtonMethod.subXTv(Kernel, Inputs, biasIndex, I, sizeI, z, g);

            for (int i = 0; i < w.Length; i++)
            {
                g[i] = w[i] + 2 * g[i];
            }

            return(g);
        }
Exemplo n.º 2
0
        private double[] hessian(double[] s)
        {
            LinearNewtonMethod.subXv(Kernel, Inputs, biasIndex, I, sizeI, s, wa);

            for (int i = 0; i < sizeI; i++)
            {
                wa[i] = C[I[i]] * wa[i];
            }

            LinearNewtonMethod.subXTv(Kernel, Inputs, biasIndex, I, sizeI, wa, h);
            for (int i = 0; i < s.Length; i++)
            {
                h[i] = s[i] + 2 * h[i];
            }

            return(h);
        }