提交 102af614 authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Added regression test for canonicalization NaN bug

上级 1e739294
## PENDING REWRITE OF tensor_opt.py ## PENDING REWRITE OF tensor_opt.py
import copy import copy
import logging
import StringIO
import time import time
import unittest import unittest
...@@ -670,6 +672,28 @@ class test_canonize(unittest.TestCase): ...@@ -670,6 +672,28 @@ class test_canonize(unittest.TestCase):
""" """
raise SkipTest("Not implemented") raise SkipTest("Not implemented")
def test_canonicalize_nan(self):
"""
Regression test for bug in canonicalization of NaN values.
This bug caused an infinite loop which was caught by the equilibrium
optimizer, resulting in an error log message.
"""
sio = StringIO.StringIO()
handler = logging.StreamHandler(sio)
handler.setLevel(logging.ERROR)
logging.getLogger('theano.gof.opt').addHandler(handler)
try:
x = vector()
f = theano.function([x], x + numpy.nan)
finally:
logging.getLogger('theano.gof.opt').removeHandler(handler)
# Ideally this test would only catch the maxed out equilibrium
# optimizer error message, but to be safe in case this message
# is modified in the future, we assert that there is no error
# at all.
assert not sio.getvalue()
def test_local_merge_abs(): def test_local_merge_abs():
x,y,z = T.matrices('xyz') x,y,z = T.matrices('xyz')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论