提交 da877d34 authored 作者: Hengjean's avatar Hengjean 提交者: Frederic

Switched back to cPickle to avoid recursion depth error

上级 713ebac8
...@@ -1079,7 +1079,7 @@ class FunctionMaker(object): ...@@ -1079,7 +1079,7 @@ class FunctionMaker(object):
opt_time: timing opt_time: timing
''' '''
from theano.gof.compilelock import get_lock, release_lock from theano.gof.compilelock import get_lock, release_lock
import pickle import cPickle
import os.path import os.path
graph_db_file = os.path.join(theano.config.compiledir, 'optimized_graphs.pkl') graph_db_file = os.path.join(theano.config.compiledir, 'optimized_graphs.pkl')
# the inputs, outputs, and size of the graph to be optimized # the inputs, outputs, and size of the graph to be optimized
...@@ -1103,7 +1103,7 @@ class FunctionMaker(object): ...@@ -1103,7 +1103,7 @@ class FunctionMaker(object):
# load the graph_db dictionary # load the graph_db dictionary
try: try:
f = open(graph_db_file, 'r+b') f = open(graph_db_file, 'r+b')
graph_db = pickle.load(f) graph_db = cPickle.load(f)
f.close() f.close()
print 'graph_db is not empty' print 'graph_db is not empty'
except EOFError, e: except EOFError, e:
...@@ -1140,7 +1140,7 @@ class FunctionMaker(object): ...@@ -1140,7 +1140,7 @@ class FunctionMaker(object):
output_new, output_old in zip(outputs_new, outputs_old)): output_new, output_old in zip(outputs_new, outputs_old)):
print 'need to optimize, because outputs are of different types' print 'need to optimize, because outputs are of different types'
continue continue
elif not len(fgraph.apply_node) == len(graph_old.apply_node): elif not len(fgraph.apply_nodes) == len(graph_old.apply_nodes):
print 'need to optimize, because numbers of nodes in graph are different' print 'need to optimize, because numbers of nodes in graph are different'
continue continue
else: else:
...@@ -1211,7 +1211,7 @@ class FunctionMaker(object): ...@@ -1211,7 +1211,7 @@ class FunctionMaker(object):
opt_time = end_optimizer - start_optimizer opt_time = end_optimizer - start_optimizer
graph_db.update({before_opt:fgraph}) graph_db.update({before_opt:fgraph})
f = open(graph_db_file, 'w+b') f = open(graph_db_file, 'w+b')
pickle.dump(graph_db, f, -1) cPickle.dump(graph_db, f, -1)
f.close() f.close()
print 'saved into graph_db' print 'saved into graph_db'
else: else:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论