提交 1e551888 authored 作者: bergstra@ip05.m's avatar bergstra@ip05.m

added mode argument to verify_grad

上级 7284da4e
...@@ -2480,7 +2480,7 @@ class numeric_grad: ...@@ -2480,7 +2480,7 @@ class numeric_grad:
return numpy.max(errs), numpy.argmax(errs) return numpy.max(errs), numpy.argmax(errs)
def verify_grad(op, pt, n_tests=2, rng=None, eps=None, tol=None): def verify_grad(op, pt, n_tests=2, rng=None, eps=None, tol=None, mode=None):
""" WRITEME """ WRITEME
Raises an Exception if the difference between the analytic gradient and Raises an Exception if the difference between the analytic gradient and
...@@ -2510,7 +2510,10 @@ def verify_grad(op, pt, n_tests=2, rng=None, eps=None, tol=None): ...@@ -2510,7 +2510,10 @@ def verify_grad(op, pt, n_tests=2, rng=None, eps=None, tol=None):
unittest_tools.seed_rng() unittest_tools.seed_rng()
def function(inputs, output): def function(inputs, output):
if mode is None:
f = compile.function(inputs, output, accept_inplace=True) f = compile.function(inputs, output, accept_inplace=True)
else:
f = compile.function(inputs, output, accept_inplace=True, mode=mode)
return f return f
for test_num in xrange(n_tests): for test_num in xrange(n_tests):
......
import sys
import elemwise_cgen as cgen import elemwise_cgen as cgen
import numpy import numpy
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论