提交 0b84931e authored 作者: Razvan Pascanu's avatar Razvan Pascanu

Op to use for testing non-differentiable pathways

上级 707084e8
......@@ -52,8 +52,30 @@ from theano import function
import theano
import theano.tensor as TT
import numpy
class test_rop(unittest.TestCase):
from theano.gof import Op, Apply
'''
Special Op created to test what happens when you have one op that is not
differentiable in the computational graph
'''
class BreakRop(Op):
"""
@note: Non-differentiable.
"""
def __hash__(self):
return hash(type(self))
def __eq__(self, other):
return type(self) == type(other)
def make_node(self, x):
return Apply(self, [x], [x.type()])
def perform(self, node, inp, out_):
x, = inp
out, = out_
out[0] = x
def grad(self, inp, grads):
return [None]
def R_op(self, inputs, eval_points):
return [None]
def test_specifyshape(self):
rng = numpy.random.RandomState(utt.fetch_seed())
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论