test_opt.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:Theano-Deep-learning 作者: GeekLiB 项目源码 文件源码
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()
        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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号