test_cuda_ndarray.py 文件源码

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

项目:Theano-Deep-learning 作者: GeekLiB 项目源码 文件源码
def test_copy():
    # print >>sys.stdout, 'starting test_copy'
    shape = (500, 499)
    a = theano._asarray(numpy.random.rand(*shape), dtype='float32')

    # print >>sys.stdout, '.. creating device object'
    b = cuda_ndarray.CudaNdarray(a)

    # print >>sys.stdout, '.. copy'
    c = copy.copy(b)
    # print >>sys.stdout, '.. deepcopy'
    d = copy.deepcopy(b)

    # print >>sys.stdout, '.. comparisons'
    assert numpy.allclose(a, numpy.asarray(b))
    assert numpy.allclose(a, numpy.asarray(c))
    assert numpy.allclose(a, numpy.asarray(d))
    b += b
    assert numpy.allclose(a + a, numpy.asarray(b))
    assert numpy.allclose(a + a, numpy.asarray(c))
    assert numpy.allclose(a, numpy.asarray(d))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号