提交 923b04d6 authored 作者: Zhouhan LIN's avatar Zhouhan LIN

adjust according to comments

上级 066a4e31
......@@ -8,7 +8,8 @@ from six.moves import StringIO
from theano import tensor, gof, Op
from theano.gradient import grad_not_implemented
import theano.tensor.clip, theano.tensor.minimum
import theano.tensor.clip
import theano.tensor.minimum
from theano.tensor.subtensor import IncSubtensor, Subtensor, get_idx_list
try:
......@@ -1149,7 +1150,6 @@ class GpuDiagonal(Subtensor):
new_dim_order = tuple(new_dim_order[:stride_axis] +
new_dim_order[stride_axis + 1:] +
[stride_axis, ])
# rval = cuda_ndarray.cuda_ndarray.dimshuffle(x[slicer], new_dim_order)
rval = x[slicer].transpose(new_dim_order)
# step 3) modify the strides in the last axis, such that rval becomes
......
......@@ -16,7 +16,7 @@ from ..subtensor import (GpuIncSubtensor, GpuSubtensor,
GpuDiagonal)
from ..type import gpuarray_shared_constructor
from .config import mode_with_gpu
from .config import mode_with_gpu, floatX
class G_subtensor(test_subtensor.T_subtensor):
......@@ -132,7 +132,7 @@ def test_adv_subtensor():
class test_gpudiagonal(unittest.TestCase):
def test_matrix(self):
x = cuda.fmatrix()
x = tensor.fmatrix()
np_x = numpy.arange(77).reshape(7, 11).astype('float32')
fn = theano.function([x], GpuDiagonal()(x), mode=mode_with_gpu)
assert numpy.allclose(fn(np_x), np_x.diagonal())
......@@ -142,8 +142,8 @@ class test_gpudiagonal(unittest.TestCase):
assert numpy.allclose(fn(np_x), np_x.diagonal(-3))
def test_tensor(self):
x = theano.tensor.ftensor4()
np_x = numpy.arange(30107).reshape(7, 11, 17, 23).astype('float32')
x = tensor.ftensor4()
np_x = numpy.arange(30107).reshape(7, 11, 17, 23).astype(floatX)
for offset, axis1, axis2 in [
(1, 0, 1), (-1, 0, 1), (0, 1, 0), (-2, 1, 0),
(-3, 1, 0), (-2, 2, 0), (3, 3, 0), (-1, 3, 2),
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论