提交 8a45c933 authored 作者: David Warde-Farley's avatar David Warde-Farley

Merge.

...@@ -51,9 +51,9 @@ copyright = '2008--2009, LISA lab' ...@@ -51,9 +51,9 @@ copyright = '2008--2009, LISA lab'
# other places throughout the built documents. # other places throughout the built documents.
# #
# The short X.Y version. # The short X.Y version.
version = '0.1' version = '0.3'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = '0.1' release = '0.3'
# There are two options for replacing |today|: either, you set today to some # There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used: # non-false value, then it is used:
......
...@@ -47,7 +47,7 @@ welcome on the mailing list. ...@@ -47,7 +47,7 @@ welcome on the mailing list.
6) Each release will be uploaded to pypi.python.org, mloss.org and freshmeat.net 6) Each release will be uploaded to pypi.python.org, mloss.org and freshmeat.net
7) Release emails will be sent to theano-users and theano-announce. 7) Release emails will be sent to theano-users, theano-announce, numpy-discussion@scipy.org and scipy-user@scipy.org .
Optional: Optional:
......
...@@ -441,6 +441,26 @@ class test_structureddot(unittest.TestCase): ...@@ -441,6 +441,26 @@ class test_structureddot(unittest.TestCase):
self.failUnless(numpy.allclose(theano_result, scipy_result)) self.failUnless(numpy.allclose(theano_result, scipy_result))
self.failIf(theano_time > overhead_rtol*scipy_time + overhead_tol) self.failIf(theano_time > overhead_rtol*scipy_time + overhead_tol)
def test_shape_i():
sparse_dtype = 'float32'
a = SparseType('csr', dtype=sparse_dtype)()
f = theano.function([a], a.shape[1], mode='FAST_RUN')
assert f(sp.csr_matrix(random_lil((100,10), sparse_dtype, 3)))==(10)
def test_shape():
sparse_dtype = 'float32'
a = SparseType('csr', dtype=sparse_dtype)()
f = theano.function([a], a.shape, mode='FAST_RUN')
assert numpy.all(f(sp.csr_matrix(random_lil((100,10), sparse_dtype, 3)))==(100,10))
if theano.config.mode!='FAST_COMPILE':
topo = f.maker.env.toposort()
assert len(topo)==3
assert isinstance(topo[0].op,tensor.opt.Shape_i)
assert isinstance(topo[1].op,tensor.opt.Shape_i)
assert isinstance(topo[2].op,tensor.opt.MakeVector)
import theano.tensor.tests.test_sharedvar import theano.tensor.tests.test_sharedvar
test_shared_options=theano.tensor.tests.test_sharedvar.makeSharedTester( test_shared_options=theano.tensor.tests.test_sharedvar.makeSharedTester(
theano.sparse.shared, 'float64', theano.sparse.shared, 'float64',
......
...@@ -1444,7 +1444,11 @@ class Shape(Op): ...@@ -1444,7 +1444,11 @@ class Shape(Op):
def __str__(self): def __str__(self):
return self.__class__.__name__ return self.__class__.__name__
def make_node(self, x): def make_node(self, x):
x = as_tensor_variable(x) if not isinstance(x, Variable):
raise TypeError('x must be Variable whose value have a shape attribute', x)
#Must work for all type that have a shape attribute.
#This will fail at execution time.
#x = as_tensor_variable(x)
return Apply(self, [x], [lvector()]) return Apply(self, [x], [lvector()])
def perform(self, node, (x, ), (out, )): def perform(self, node, (x, ), (out, )):
out[0] = theano._asarray(x.shape, dtype = 'int64') out[0] = theano._asarray(x.shape, dtype = 'int64')
......
...@@ -465,7 +465,7 @@ class ShapeFeature(object): ...@@ -465,7 +465,7 @@ class ShapeFeature(object):
""" """
def shape_i(self, i): def shape_i(self, i):
def op_deco(r): def op_deco(r):
if r.type.broadcastable[i]: if hasattr(r.type,"broadcastable") and r.type.broadcastable[i]:
return self.lscalar_one return self.lscalar_one
else: else:
return Shape_i(i)(r) return Shape_i(i)(r)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论