提交 3d818ece authored 作者: Frederic Bastien's avatar Frederic Bastien

Do not raise warning when the old code was working correctly.

上级 e53129ba
...@@ -1119,8 +1119,13 @@ def inc_subtensor(x, y, inplace=False, set_instead_of_inc=False, ...@@ -1119,8 +1119,13 @@ def inc_subtensor(x, y, inplace=False, set_instead_of_inc=False,
# We also explicitly duplicate y to its broadcasted shape # We also explicitly duplicate y to its broadcasted shape
# before we partially flatten it to inner_x dimension. This is # before we partially flatten it to inner_x dimension. This is
# not strictly needed in all cases, but it is easier this way. # not strictly needed in all cases, but it is easier this way.
expanded_y = alloc(y, *[x.shape[i] for i in range(x.ndim)]) if y.ndim > 0:
flattened_y = expanded_y.flatten(inner_x.ndim) # This if is needed to prevent some useless warning about
# old code bug.
expanded_y = alloc(y, *[x.shape[i] for i in range(x.ndim)])
flattened_y = expanded_y.flatten(inner_x.ndim)
else:
flattened_y = y
# Warn if this code path would have produced wrong results in the past # Warn if this code path would have produced wrong results in the past
if config.warn.inc_set_subtensor1: if config.warn.inc_set_subtensor1:
......
...@@ -1035,15 +1035,8 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin): ...@@ -1035,15 +1035,8 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
m = matrix('m') m = matrix('m')
i = lmatrix('i') i = lmatrix('i')
# That test actually gave correct results, the warning is m1 = set_subtensor(m[:, i], 0)
# a bit too broad m2 = inc_subtensor(m[:, i], 1)
orig_warn = config.warn.inc_set_subtensor1
try:
config.warn.inc_set_subtensor1 = False
m1 = set_subtensor(m[:, i], 0)
m2 = inc_subtensor(m[:, i], 1)
finally:
config.warn.inc_set_subtensor1 = orig_warn
f = theano.function([m, i], [m1, m2]) f = theano.function([m, i], [m1, m2])
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论