提交 45a1ad4a authored 作者: Frederic Bastien's avatar Frederic Bastien

Change default of round() to be as NumPy and warn about it.

上级 f33a3315
......@@ -585,7 +585,7 @@ import theano and print the config variable, as in:
.. attribute:: config.warn.ignore_bug_before
String value: ``'None'``, ``'all'``, ``'0.3'``, ``'0.4'``, ``'0.4.1'``, ``'0.5'``,
``'0.6'``, ``'0.7'``, ``'0.8'``, ``'0.8.1'``, ``'0.8.2'``
``'0.6'``, ``'0.7'``, ``'0.8'``, ``'0.8.1'``, ``'0.8.2'``, ``'0.9'``
Default: ``'0.7'``
......
......@@ -692,7 +692,7 @@ AddConfigVar('warn.ignore_bug_before',
"Warning for specific bugs can be configured with specific "
"[warn] flags."),
EnumStr('0.7', 'None', 'all', '0.3', '0.4', '0.4.1', '0.5', '0.6',
'0.7', '0.8', '0.8.1', '0.8.2',
'0.7', '0.8', '0.8.1', '0.8.2', '0.9',
allow_override=False),
in_c_key=False)
......@@ -796,6 +796,13 @@ AddConfigVar('warn.inc_set_subtensor1',
BoolParam(warn_default('0.7')),
in_c_key=False)
AddConfigVar('warn.round',
"Round changed its default from Seed to use for randomized unit tests. "
"Special value 'random' means using a seed of None.",
BoolParam(warn_default('0.9')),
in_c_key=False)
AddConfigVar(
'compute_test_value',
("If 'True', Theano will run each op at graph build time, using "
......
......@@ -2128,14 +2128,23 @@ def trunc(a):
@constructor
def iround(a, mode="half_away_from_zero"):
def iround(a, mode=None):
"""cast(round(a,mode),'int64')"""
return cast(round(a, mode), 'int64')
@constructor
def round(a, mode="half_away_from_zero"):
"""round_mode(a) with mode in [half_away_from_zero, half_to_even]"""
def round(a, mode=None):
"""round_mode(a) with mode in [half_away_from_zero, half_to_even].
Default to half_to_even."""
if mode is None:
mode = "half_to_even"
if config.warn.round:
warnings.warn(
"theano.tensor.round() changed its default from"
" `half_away_from_zero` to `half_to_even` to have"
" the same default as NumPy. Use the Theano flag"
" `warn.round=False` to disable this warning.")
if mode == "half_away_from_zero":
return round_half_away_from_zero(a)
elif mode == "half_to_even":
......
......@@ -711,7 +711,7 @@ class _tensor_py_operators(object):
"""See `theano.tensor.repeat`."""
return theano.tensor.extra_ops.repeat(self, repeats, axis)
def round(self, mode="half_away_from_zero"):
def round(self, mode=None):
"""See `theano.tensor.round`."""
return theano.tensor.basic.round(self, mode)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论