提交 29ea70d6 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Remove import of unittest_tools in basic.py. tensor.verify_grad now needs to be passed a valid rng.

上级 488246bf
......@@ -3548,7 +3548,7 @@ class numeric_grad:
def verify_grad(op, pt, n_tests=2, rng=None, eps=None, tol=None, mode=None, cast_to_output_type=False):
""" WRITEME
Raises an Exception if the difference between the analytic gradient and
numerical gradient (computed through the Finite Difference Method) exceeds
the given tolerance.
......@@ -3565,7 +3565,7 @@ def verify_grad(op, pt, n_tests=2, rng=None, eps=None, tol=None, mode=None, cast
try to make it a SMALL graph. Often verify grad is run in
debug mode, which can be very slow if it has to verify a lot
of intermediate computations.
"""
pt = [numpy.array(p) for p in pt]
......@@ -3577,9 +3577,8 @@ def verify_grad(op, pt, n_tests=2, rng=None, eps=None, tol=None, mode=None, cast
tol = __builtin__.max(_type_tol[str(p.dtype)] for p in pt)
if rng is None:
rng = numpy.random
from theano import tests as theano_tests # TODO This is an ugly import. Fix?
theano_tests.unittest_tools.seed_rng()
raise TypeError('rng should be a valid instance of numpy.random.RandomState.',
'You may want to use theano.tests.unittest_tools.verify_grad instead of theano.tensor.verify_grad.')
def function(inputs, output):
if mode is None:
......@@ -3591,9 +3590,9 @@ def verify_grad(op, pt, n_tests=2, rng=None, eps=None, tol=None, mode=None, cast
for test_num in xrange(n_tests):
tensor_pt = [value(p.copy(), name='input %i'%i) for i,p in enumerate(pt)]
#op can be either a function or an actual Op instance
o_output = op(*tensor_pt)
o_output = op(*tensor_pt)
if isinstance(o_output,list) > 1:
raise NotImplementedError('cant (yet) autotest gradient of op with multiple outputs')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论