def test_setitem_matrixvector1():
a = theano._asarray([[0, 1, 2], [3, 4, 5]], dtype='float32')
_a = cuda_ndarray.CudaNdarray(a)
b = theano._asarray([8, 9], dtype='float32')
_b = cuda_ndarray.CudaNdarray(b)
# set second column to 8,9
_a[:, 1] = _b
a[:, 1] = b
assert numpy.allclose(a, numpy.asarray(_a))
# test direct transfert from numpy
_a[:, 1] = b * 100
a[:, 1] = b * 100
assert numpy.allclose(a, numpy.asarray(_a))
row = theano._asarray([777, 888, 999], dtype='float32')
_a[1, :] = row
a[1, :] = row
assert numpy.allclose(a, numpy.asarray(_a))
评论列表
文章目录