提交 6199271a authored 作者: Ian Goodfellow's avatar Ian Goodfellow

changed some None grads to undefined

上级 3575d39a
...@@ -24,6 +24,7 @@ from theano.tensor.utils import hash_from_ndarray ...@@ -24,6 +24,7 @@ from theano.tensor.utils import hash_from_ndarray
# We use these exceptions as well. # We use these exceptions as well.
from theano.scalar import ComplexError, IntegerDivisionError from theano.scalar import ComplexError, IntegerDivisionError
import theano.scalar.sharedvar import theano.scalar.sharedvar
from theano.gradient import grad_undefined
### set up the external interface ### set up the external interface
from elemwise import Elemwise, DimShuffle, CAReduce, Sum from elemwise import Elemwise, DimShuffle, CAReduce, Sum
...@@ -2094,7 +2095,7 @@ class Shape(Op): ...@@ -2094,7 +2095,7 @@ class Shape(Op):
return [[len(in_shapes[0])]] return [[len(in_shapes[0])]]
def grad(self, inp, grads): def grad(self, inp, grads):
return [None] return [grad_undefined(self,0,inp[0])]
def R_op(self, inputs, eval_points): def R_op(self, inputs, eval_points):
return [None] return [None]
...@@ -2335,7 +2336,7 @@ class MaxAndArgmax(Op): ...@@ -2335,7 +2336,7 @@ class MaxAndArgmax(Op):
# Set the grad to the correct position. # Set the grad to the correct position.
g_x = eq(xmax_pad, x) * g_max_pad g_x = eq(xmax_pad, x) * g_max_pad
return g_x, None return g_x, grad_undefined(self, axis, 1)
def __str__(self): def __str__(self):
return self.__class__.__name__ return self.__class__.__name__
...@@ -2916,7 +2917,7 @@ class Eye(gof.Op): ...@@ -2916,7 +2917,7 @@ class Eye(gof.Op):
return [out_shape] return [out_shape]
def grad(self, inp, grads): def grad(self, inp, grads):
return [None, None, None] return [ grad_undefined(self,i,inp[i]) for i in xrange(3) ]
def __eq__(self, other): def __eq__(self, other):
return type(self) == type(other) and self.dtype == other.dtype return type(self) == type(other) and self.dtype == other.dtype
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论