提交 dd4f0c5c authored 作者: nouiz's avatar nouiz

Merge pull request #332 from pascanur/bug_subtensor_merge

Bug subtensor merge
......@@ -23,6 +23,7 @@ from theano.printing import pprint, min_informative_str
# We use these exceptions as well.
from theano.scalar import ComplexError, IntegerDivisionError
import theano.scalar.sharedvar
### set up the external interface
from elemwise import Elemwise, DimShuffle, CAReduce, Sum
......
......@@ -2508,6 +2508,22 @@ class T_subtensor(unittest.TestCase):
assert numpy.all(t_out == v_out)
assert numpy.all(t_out.shape == v_out.shape)
def test_merge_subtensor(self):
# Bug reported by Razvan
data = numpy.asarray(numpy.arange(8),
dtype = theano.config.floatX)
x = theano.tensor.vector()
y1 = x[2:][::-1]
y2 = x[:-2][::-1]
length = theano.tensor.minimum(y1.shape[0], y2.shape[0])
y1 = y1[:length]
y2 = y2[:length]
t = theano.shared(numpy.int64(0))
fun = theano.function([x], [y1[t], y2[t]])
val0, val1 = fun(data)
assert val0 == data[2:][::-1][0]
assert val1 == data[:-2][::-1][0]
def grad_list_(self, idxs, data):
n = self.shared(data)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论