提交 54bc8d12 authored 作者: Li's avatar Li 提交者: Frederic

addresses some of the cosmatic changes

上级 d4b03a78
...@@ -5,14 +5,6 @@ from theano.gof.graph import is_same_graph ...@@ -5,14 +5,6 @@ from theano.gof.graph import is_same_graph
from theano.gof import FunctionGraph from theano.gof import FunctionGraph
from theano.scan_module.scan_utils import equal_computations from theano.scan_module.scan_utils import equal_computations
def graphs_equal(x, y):
# check if two graphs are equal
# x: outputs list of graph A
# y: outputs list of graph B
pass
def test_graph_equivalence(): def test_graph_equivalence():
# Test if equivalent graphs are in fact equivalent # Test if equivalent graphs are in fact equivalent
# by using some functions in Theano # by using some functions in Theano
...@@ -44,14 +36,5 @@ def test_graph_equivalence(): ...@@ -44,14 +36,5 @@ def test_graph_equivalence():
#assert graphs_equal(g1_y, g3_y) == True #assert graphs_equal(g1_y, g3_y) == True
#assert graphs_equal(g1_y, g2_y) == False #assert graphs_equal(g1_y, g2_y) == False
def test_graph_optimization_caching():
#
x = T.fmatrix('inputs')
y = x.sum()
f = theano.function(inputs=[x], outputs=y)
if __name__ == '__main__': if __name__ == '__main__':
test_graph_optimization_caching() test_graph_equivalence()
#test_graph_equivalence()
...@@ -3,7 +3,7 @@ import theano ...@@ -3,7 +3,7 @@ import theano
import theano.tensor as T import theano.tensor as T
import numpy import numpy
import cPickle import cPickle
from collections import OrderedDict
floatX = 'float32' floatX = 'float32'
def test_pickle_unpickle(): def test_pickle_unpickle():
...@@ -14,19 +14,23 @@ def test_pickle_unpickle(): ...@@ -14,19 +14,23 @@ def test_pickle_unpickle():
x3 = theano.shared(numpy.ones((10,10),dtype=floatX)) x3 = theano.shared(numpy.ones((10,10),dtype=floatX))
x4 = theano.shared(numpy.ones((10,10),dtype=floatX)) x4 = theano.shared(numpy.ones((10,10),dtype=floatX))
y = T.sum(T.sum(T.sum(x1**2+x2) + x3) + x4) y = T.sum(T.sum(T.sum(x1**2+x2) + x3) + x4)
f = theano.function([x1,x2],y) updates = OrderedDict()
updates[x3] = x3 + 1
updates[x4] = x4 + 1
f = theano.function([x1,x2],y, updates=updates)
pkl_path = open('thean_fn.pkl','wb') pkl_path = open('thean_fn.pkl','wb')
cPickle.dump(f, pkl_path, -1) cPickle.dump(f, pkl_path, -1)
pkl_path = open('thean_fn.pkl','r') pkl_path = open('thean_fn.pkl','r')
f_ = cPickle.load(pkl_path) f_ = cPickle.load(pkl_path)
in1 = numpy.ones((10,10), dtype=floatX) in1 = numpy.ones((10, 10), dtype=floatX)
in2 = numpy.ones((10,10), dtype=floatX) in2 = numpy.ones((10, 10), dtype=floatX)
assert f(in1,in2) == f_(in1,in2) assert f(in1, in2) == f_(in1, in2)
print f(in1,in2)
print f(in1, in2)
if __name__ == '__main__': if __name__ == '__main__':
test_pickle_unpickle() test_pickle_unpickle()
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论