test_basic.py 文件源码

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

项目:Theano-Deep-learning 作者: GeekLiB 项目源码 文件源码
def test_composite_neg_bool(self):
        # Check that taking the negation of a Boolean intermediate value
        # works correctly with Python code. It used to be an issue because
        # `-numpy.bool_(True)` is False and `-numpy.bool_(False)` is True.
        x = floats('x')
        y = - (x > 0)
        z = Composite([x], [y]).make_node(x).outputs[0]
        f = theano.function([x], z, mode=theano.Mode(linker='py'))
        for inp, out in zip([-1, 0, 1], [0, 0, -1]):
            self.assertTrue(f(inp) == out)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号