test_basic.py 文件源码

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

项目:Theano-Deep-learning 作者: GeekLiB 项目源码 文件源码
def test_eq(self):
        for dtype in self.dtypes:
            l = numpy.asarray([0., -1., 1.], dtype=dtype)
            r = numpy.asarray([0., 1., -1.], dtype=dtype)
            for x, y, err in [
                (self.shared(l.astype(dtype)),
                 self.shared(r.astype(dtype)), False),
                (l, self.shared(r.astype(dtype)), True),
                (tensor.constant(l), self.shared(r.astype(dtype)), False),
                (self.shared(l.astype(dtype)), r, False),
                (self.shared(l.astype(dtype)), tensor.constant(r), False),
            ]:
                try:
                    fn = self.inplace_func([], eq(x, y))
                    v = fn()
                    self.assertTrue(numpy.all(v == (l == r)), (v, (l == r)))
                except TypeError:
                    assert err
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号