提交 7c5a4271 authored 作者: abergeron's avatar abergeron 提交者: GitHub

Merge pull request #6319 from yikangshen/pickling_test_flag

Flag to disable pickling test values
...@@ -55,6 +55,13 @@ AddConfigVar('warn_float64', ...@@ -55,6 +55,13 @@ AddConfigVar('warn_float64',
in_c_key=False, in_c_key=False,
) )
AddConfigVar('pickle_test_value',
"Dump test values while pickling model. "
"If True, test values will be dumped with model.",
BoolParam(True),
in_c_key=False,
)
AddConfigVar('cast_policy', AddConfigVar('cast_policy',
'Rules for implicit type casting', 'Rules for implicit type casting',
EnumStr('custom', 'numpy+floatX', EnumStr('custom', 'numpy+floatX',
......
...@@ -7,6 +7,8 @@ from collections import deque ...@@ -7,6 +7,8 @@ from collections import deque
from copy import copy from copy import copy
from itertools import count from itertools import count
import warnings
import theano import theano
from theano import config from theano import config
from theano.gof import utils from theano.gof import utils
...@@ -524,6 +526,14 @@ class Variable(Node): ...@@ -524,6 +526,14 @@ class Variable(Node):
def __getstate__(self): def __getstate__(self):
d = self.__dict__.copy() d = self.__dict__.copy()
d.pop("_fn_cache", None) d.pop("_fn_cache", None)
if (not config.pickle_test_value) \
and (hasattr(self.tag, 'test_value')) \
and (not type(config).pickle_test_value.is_default):
warnings.warn("pickle_test_value is not defaut value (True).\n"
"Test value of variable %s(%s) will not be dumped." % (d['auto_name'], d['name']))
t = copy(d["tag"])
del t.test_value
d["tag"] = t
return d return d
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论