Esempio n. 1
0
                                            check_floatX, upcast_int8_nfunc,
                                            _good_broadcast_unary_normal_no_complex)


class T_sigmoid(unittest.TestCase):
    def setUp(self):
        utt.seed_rng()

    def test_elemwise(self):
        utt.verify_grad(sigmoid, [numpy.random.rand(3, 4)])


SigmoidTester = makeBroadcastTester(
    op=sigmoid,
    expected=upcast_int8_nfunc(lambda inputs: check_floatX(
        inputs, 1 / (1 + numpy.exp(-inputs)))),
    good=_good_broadcast_unary_normal_no_complex,
    # grad=_grad_broadcast_unary_normal,
    name='SigmoidTester',
)

UltraFastSigmoidTester = makeBroadcastTester(
    op=ultra_fast_sigmoid,
    expected=upcast_int8_nfunc(lambda inputs: check_floatX(
        inputs, 1 / (1 + numpy.exp(-inputs)))),
    good=_good_broadcast_unary_normal_no_complex,
    # grad=_grad_broadcast_unary_normal,
    name='UltraFastSigmoidTester',
# This is an approx of the sigmoid. That is why we raise eps
    eps=5e-2)

HardSigmoidTester = makeBroadcastTester(
Esempio n. 2
0
                                            _good_broadcast_unary_normal_no_complex)


class T_sigmoid(unittest.TestCase):
    def setUp(self):
        utt.seed_rng()

    def test_elemwise(self):
        utt.verify_grad(sigmoid, [np.random.rand(3, 4)])

SigmoidTester = makeBroadcastTester(
    op=sigmoid,
    expected=upcast_int8_nfunc(lambda inputs: check_floatX(
        inputs, 1 / (1 + np.exp(-inputs)))),
    good=copymod(_good_broadcast_unary_normal_no_complex,
                 without=['uint16']),  # The reason that 'uint16' is excluted is that
                                       # theano works well but numpy overflows resulting
                                       # in an assertion error.
    # grad=_grad_broadcast_unary_normal,
    name='SigmoidTester',
)

UltraFastSigmoidTester = makeBroadcastTester(
    op=ultra_fast_sigmoid,
    expected=upcast_int8_nfunc(lambda inputs: check_floatX(
        inputs, 1 / (1 + np.exp(-inputs)))),
    good=copymod(_good_broadcast_unary_normal_no_complex,
                 without=['uint16']),  # numpy fucnting overflows with uint16.
    # grad=_grad_broadcast_unary_normal,
    name='UltraFastSigmoidTester',
    # This is an approx of the sigmoid. That is why we raise eps
Esempio n. 3
0
from theano.tensor.tests.test_basic import (
    expected_chi2sf, _good_broadcast_unary_chi2sf,
    makeBroadcastTester, mode_no_scipy, skip_scipy)

from theano_lgpl.elemwise_c import cchi2sf

CChi2SFTester = makeBroadcastTester(
    op=cchi2sf,
    expected=expected_chi2sf,
    good=_good_broadcast_unary_chi2sf,
    eps=2e-10,
    mode=mode_no_scipy,
    skip=skip_scipy,
    name='CChi2SFTester',
    check_name=False)
Esempio n. 4
0
    _good_broadcast_unary_normal_no_complex,
)


class T_sigmoid(unittest.TestCase):
    def setUp(self):
        utt.seed_rng()

    def test_elemwise(self):
        utt.verify_grad(sigmoid, [numpy.random.rand(3, 4)])


SigmoidTester = makeBroadcastTester(
    op=sigmoid,
    expected=lambda inputs: check_floatX(inputs, 1 / (1 + numpy.exp(-inputs))),
    good=_good_broadcast_unary_normal_no_complex,
    # grad=_grad_broadcast_unary_normal,
    name="SigmoidTester",
)

UltraFastSigmoidTester = makeBroadcastTester(
    op=ultra_fast_sigmoid,
    expected=lambda inputs: check_floatX(inputs, 1 / (1 + numpy.exp(-inputs))),
    good=_good_broadcast_unary_normal_no_complex,
    # grad=_grad_broadcast_unary_normal,
    name="UltraFastSigmoidTester",
    # This is an approx of the sigmoid. That is why we raise eps
    eps=5e-2,
)

HardSigmoidTester = makeBroadcastTester(
Esempio n. 5
0
    makeBroadcastTester, rand, check_floatX, upcast_int8_nfunc,
    _good_broadcast_unary_normal_no_complex)


class T_sigmoid(unittest.TestCase):
    def setUp(self):
        utt.seed_rng()

    def test_elemwise(self):
        utt.verify_grad(sigmoid, [numpy.random.rand(3, 4)])


SigmoidTester = makeBroadcastTester(
    op=sigmoid,
    expected=upcast_int8_nfunc(
        lambda inputs: check_floatX(inputs, 1 / (1 + numpy.exp(-inputs)))),
    good=_good_broadcast_unary_normal_no_complex,
    # grad=_grad_broadcast_unary_normal,
    name='SigmoidTester',
)

UltraFastSigmoidTester = makeBroadcastTester(
    op=ultra_fast_sigmoid,
    expected=upcast_int8_nfunc(
        lambda inputs: check_floatX(inputs, 1 / (1 + numpy.exp(-inputs)))),
    good=_good_broadcast_unary_normal_no_complex,
    # grad=_grad_broadcast_unary_normal,
    name='UltraFastSigmoidTester',
    # This is an approx of the sigmoid. That is why we raise eps
    eps=5e-2)

HardSigmoidTester = makeBroadcastTester(