提交 58e91610 authored 作者: Frederic Bastien's avatar Frederic Bastien

make the shape op work for sparse type.

上级 351354da
......@@ -1444,7 +1444,11 @@ class Shape(Op):
def __str__(self):
return self.__class__.__name__
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()])
def perform(self, node, (x, ), (out, )):
out[0] = theano._asarray(x.shape, dtype = 'int64')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论