public void Visit(Compiled.LinSigmoid elem)
            {
                Debug.Assert(ArgumentIndex == 0 || ArgumentIndex == 1);
                double e = Math.Exp((-ValueOf(elem.Arg)));

                if (Double.IsPositiveInfinity(e) || e == 0)
                {
                    if (ArgumentIndex == 0)
                    {
                        LocalDerivative = elem.Adjoint * Epsilon;
                    }
                    else
                    {
                        LocalDerivative = -elem.Adjoint * Epsilon;
                    }
                }
                else
                if (ArgumentIndex == 0)
                {
                    LocalDerivative = elem.Adjoint * e / ((e + 1) * (e + 1));
                    if (Math.Abs(LocalDerivative) < Math.Abs(elem.Adjoint * Epsilon))
                    {
                        LocalDerivative = elem.Adjoint * Epsilon;
                    }
                }
                else
                {
                    LocalDerivative = -elem.Adjoint * e / ((e + 1) * (e + 1));
                    if (Math.Abs(LocalDerivative) < Math.Abs(elem.Adjoint * Epsilon))
                    {
                        LocalDerivative = -elem.Adjoint * Epsilon;
                    }
                }
            }
Example #2
0
            public void Visit(Compiled.LinSigmoid elem)
            {
                double arg = ValueOf(elem.Arg);
                double e   = Math.Exp(-arg);

                if (Double.IsPositiveInfinity(e))
                {
                    elem.Value = Term.Epsilon;
                }
                else
                {
                    elem.Value = 1.0 / (1.0 + e);
                }
                if (elem.Value < Term.Epsilon)
                {
                    elem.Value = Term.Epsilon;
                }
                if (e == 0.0 || Double.IsPositiveInfinity(e))
                {
                    elem.Inputs[0].Weight = Term.Epsilon;
                    elem.Inputs[1].Weight = -Term.Epsilon;
                    return;
                }
                double e2 = e / ((e + 1) * (e + 1));

                elem.Inputs[0].Weight = e2;
                elem.Inputs[1].Weight = -e2;
            }
            public void Visit(Compiled.LinSigmoid elem)
            {
                double e = Math.Exp((-ValueOf(elem.Arg)));

                if (Double.IsPositiveInfinity(e))
                {
                    elem.Value = Term.Epsilon;
                    //Console.WriteLine("FUCKUP {0}",e);
                }
                else
                {
                    elem.Value = 1.0 / (1.0 + e);
                }
                if (elem.Value < Term.Epsilon)
                {
                    elem.Value = Term.Epsilon;
                }
            }