提交 834e31d0 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

random_projection elements are now in [.5, 1.5] instead of [0, 1] to avoid two small coefficients.

上级 40548f8f
...@@ -3588,8 +3588,10 @@ def verify_grad(op, pt, n_tests=2, rng=None, eps=None, tol=None, mode=None, cast ...@@ -3588,8 +3588,10 @@ def verify_grad(op, pt, n_tests=2, rng=None, eps=None, tol=None, mode=None, cast
o_fn = function(tensor_pt, o_output) o_fn = function(tensor_pt, o_output)
o_fn_out = o_fn(*[p.copy() for p in pt]) o_fn_out = o_fn(*[p.copy() for p in pt])
random_projection = rng.rand(*o_fn_out.shape) # random_projection should not have elements too small,
# otherwise too much precision is lost in numerical gradient
random_projection = rng.rand(*o_fn_out.shape) + 0.5
if cast_to_output_type: if cast_to_output_type:
random_projection = numpy.array(random_projection, random_projection = numpy.array(random_projection,
dtype=o_output.dtype) dtype=o_output.dtype)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论