Beispiel #1
0
 def test_compute_mul(self):
     x, y, z = tensor.vectors('x', 'y', 'z')
     tree = (x * y) * -z
     mul_tree = parse_mul_tree(tree)
     assert parse_mul_tree(compute_mul(mul_tree)) == mul_tree
     assert theano.gof.graph.is_same_graph(
         compute_mul(parse_mul_tree(tree)), tree)
Beispiel #2
0
 def test_compute_mul(self):
     x, y, z = tensor.vectors('x', 'y', 'z')
     tree = (x * y) * -z
     mul_tree = parse_mul_tree(tree)
     assert parse_mul_tree(compute_mul(mul_tree)) == mul_tree
     assert theano.gof.graph.is_same_graph(
                                 compute_mul(parse_mul_tree(tree)), tree)
Beispiel #3
0
 def test_parse_mul_tree(self):
     x, y, z = tensor.vectors("x", "y", "z")
     assert parse_mul_tree(x * y) == [False, [[False, x], [False, y]]]
     assert parse_mul_tree(-(x * y)) == [True, [[False, x], [False, y]]]
     assert parse_mul_tree(-x * y) == [False, [[True, x], [False, y]]]
     assert parse_mul_tree(-x) == [True, x]
     assert parse_mul_tree((x * y) * -z) == [False, [[False, [[False, x], [False, y]]], [True, z]]]
Beispiel #4
0
 def test_parse_mul_tree(self):
     x, y, z = tensor.vectors('x', 'y', 'z')
     assert parse_mul_tree(x * y) == [False, [[False, x], [False, y]]]
     assert parse_mul_tree(-(x * y)) == [True, [[False, x], [False, y]]]
     assert parse_mul_tree(-x * y) == [False, [[True, x], [False, y]]]
     assert parse_mul_tree(-x) == [True, x]
     assert parse_mul_tree((x * y) * -z) == [
                     False, [[False, [[False, x], [False, y]]], [True, z]]]
Beispiel #5
0
 def test_parse_mul_tree(self):
     x, y, z = tt.vectors("x", "y", "z")
     assert parse_mul_tree(x * y) == [False, [[False, x], [False, y]]]
     assert parse_mul_tree(-(x * y)) == [True, [[False, x], [False, y]]]
     assert parse_mul_tree(-x * y) == [False, [[True, x], [False, y]]]
     assert parse_mul_tree(-x) == [True, x]
     assert parse_mul_tree((x * y) * -z) == [
         False,
         [[False, [[False, x], [False, y]]], [True, z]],
     ]
Beispiel #6
0
 def ok(expr1, expr2):
     trees = [parse_mul_tree(e) for e in (expr1, expr2)]
     perform_sigm_times_exp(trees[0])
     trees[0] = simplify_mul(trees[0])
     good = is_same_graph(compute_mul(trees[0]), compute_mul(trees[1]))
     if not good:
         print(trees[0])
         print(trees[1])
         print("***")
         theano.printing.debugprint(compute_mul(trees[0]))
         print("***")
         theano.printing.debugprint(compute_mul(trees[1]))
     assert good
Beispiel #7
0
 def ok(expr1, expr2):
     trees = [parse_mul_tree(e) for e in (expr1, expr2)]
     perform_sigm_times_exp(trees[0])
     trees[0] = simplify_mul(trees[0])
     good = theano.gof.graph.is_same_graph(compute_mul(trees[0]), compute_mul(trees[1]))
     if not good:
         print trees[0]
         print trees[1]
         print "***"
         theano.printing.debugprint(compute_mul(trees[0]))
         print "***"
         theano.printing.debugprint(compute_mul(trees[1]))
     assert good
Beispiel #8
0
 def test_compute_mul(self):
     x, y, z = tt.vectors("x", "y", "z")
     tree = (x * y) * -z
     mul_tree = parse_mul_tree(tree)
     assert parse_mul_tree(compute_mul(mul_tree)) == mul_tree
     assert is_same_graph(compute_mul(parse_mul_tree(tree)), tree)