Exemple #1
0
 def test_is_1pexp(self):
     backup = config.warn.identify_1pexp_bug
     config.warn.identify_1pexp_bug = False
     try:
         x = tensor.vector('x')
         exp = tensor.exp
         assert is_1pexp(1 + exp(x), False) == (False, x)
         assert is_1pexp(exp(x) + 1, False) == (False, x)
         for neg, exp_arg in imap(
                 lambda x: is_1pexp(x, only_process_constants=False),
             [(1 + exp(-x)), (exp(-x) + 1)]):
             assert not neg and theano.gof.graph.is_same_graph(exp_arg, -x)
         assert is_1pexp(1 - exp(x), False) is None
         assert is_1pexp(2 + exp(x), False) is None
         assert is_1pexp(exp(x) + 2, False) is None
         assert is_1pexp(exp(x) - 1, False) is None
         assert is_1pexp(-1 + exp(x), False) is None
         assert is_1pexp(1 + 2 * exp(x), False) is None
     finally:
         config.warn.identify_1pexp_bug = backup
Exemple #2
0
 def test_is_1pexp(self):
     backup = config.warn.identify_1pexp_bug
     config.warn.identify_1pexp_bug = False
     try:
         x = tensor.vector('x')
         exp = tensor.exp
         assert is_1pexp(1 + exp(x), False) == (False, x)
         assert is_1pexp(exp(x) + 1, False) == (False, x)
         for neg, exp_arg in imap(lambda x:
                                  is_1pexp(x, only_process_constants=False),
                                  [(1 + exp(-x)), (exp(-x) + 1)]):
             assert not neg and theano.gof.graph.is_same_graph(exp_arg, -x)
         assert is_1pexp(1 - exp(x), False) is None
         assert is_1pexp(2 + exp(x), False) is None
         assert is_1pexp(exp(x) + 2, False) is None
         assert is_1pexp(exp(x) - 1, False) is None
         assert is_1pexp(-1 + exp(x), False) is None
         assert is_1pexp(1 + 2 * exp(x), False) is None
     finally:
         config.warn.identify_1pexp_bug = backup
Exemple #3
0
 def test_is_1pexp(self):
     backup = config.warn.identify_1pexp_bug
     config.warn.identify_1pexp_bug = False
     try:
         x = tensor.vector('x')
         exp = tensor.exp
         assert is_1pexp(1 + exp(x)) == (False, x)
         assert is_1pexp(exp(x) + 1) == (False, x)
         for neg, exp_arg in imap(is_1pexp, [(1 + exp(-x)), (exp(-x) + 1)]):
             assert not neg and theano.gof.graph.is_same_graph(exp_arg, -x)
         assert is_1pexp(1 - exp(x)) is None
         assert is_1pexp(2 + exp(x)) is None
         assert is_1pexp(exp(x) + 2) is None
         assert is_1pexp(exp(x) - 1) is None
         assert is_1pexp(-1 + exp(x)) is None
         assert is_1pexp(1 + 2 * exp(x)) is None
     finally:
         config.warn.identify_1pexp_bug = backup