def grad(self, inp, grads): """ """ x, = inp gz, = grads cst = numpy.asarray(-2. / numpy.sqrt(numpy.pi), dtype=upcast(x.type.dtype, gz.type.dtype)) return gz * (cst + 2. * x * exp(-x * x) * erfcx(x)),
def grad(self, inputs, gout): (x, ) = inputs (gz, ) = gout # rval = x.zeros_like() # if rval.type.dtype in discrete_types: # rval = rval.astype(theano.config.floatX) return [gz * exp(-1.0 * abs_(x))]
def grad(self, inp, grads): x, = inp gz, = grads if x.type in complex_types: raise NotImplementedError() elif x.type in float_types: cst = numpy.asarray(numpy.sqrt(numpy.pi) / 2.0, dtype=upcast(x.type.dtype, gz.type.dtype)) return (gz * cst * exp(erfinv(x) ** 2),) else: return (None,)
def grad(self, inp, grads): x, = inp gz, = grads if x.type in complex_types: raise NotImplementedError() elif x.type in float_types: cst = numpy.asarray(2. / numpy.sqrt(numpy.pi),dtype=upcast(x.type.dtype,gz.type.dtype)) return - gz * cst * exp(-x*x), else: return None,
class Erf(UnaryScalarOp): def impl(self, x): return scipy.special.erf(x) def grad(self, (x, ), (gz, )): if x.type in complex_types: raise NotImplementedError() elif x.type in float_types: return gz * 2. / numpy.sqrt(numpy.pi) * exp(-x * x), else: return None,
def grad(self, inp, grads): x, = inp gz, = grads if x.type in complex_types: raise NotImplementedError() if self(x).type in discrete_types: if x.type in discrete_types: return [x.zeros_like(dtype=theano.config.floatX)] else: return [x.zeros_like()] cst = numpy.asarray(2.0 / numpy.sqrt(numpy.pi), dtype=upcast(x.type.dtype, gz.type.dtype)) return (-gz * cst * exp(-x * x),)
def L_op(self, inputs, outputs, grads): x, = inputs gz, = grads if x.type in complex_types: raise NotImplementedError() if outputs[0].type in discrete_types: if x.type in discrete_types: return [x.zeros_like(dtype=theano.config.floatX)] else: return [x.zeros_like()] cst = numpy.asarray(2. / numpy.sqrt(numpy.pi), dtype=upcast(x.type.dtype, gz.type.dtype)) return -gz * cst * exp(-x * x),
def grad(self, inp, grads): x, = inp gz, = grads if x.type in complex_types: raise NotImplementedError() if self(x).type in discrete_types: if x.type in discrete_types: return [x.zeros_like(dtype=theano.config.floatX)] else: return [x.zeros_like()] cst = numpy.asarray(numpy.sqrt(numpy.pi) / 2., dtype=upcast(x.type.dtype, gz.type.dtype)) return -gz * cst * exp(erfcinv(x)**2),
def L_op(self, inputs, outputs, grads): x, = inputs gz, = grads if x.type in complex_types: raise NotImplementedError() if outputs[0].type in discrete_types: if x.type in discrete_types: return [x.zeros_like(dtype=theano.config.floatX)] else: return [x.zeros_like()] cst = np.asarray(np.sqrt(np.pi) / 2., dtype=upcast(x.type.dtype, gz.type.dtype)) return gz * cst * exp(erfinv(x)**2),
def L_op(self, inputs, outputs, grads): x, = inputs gz, = grads if x.type in complex_types: raise NotImplementedError() if outputs[0].type in discrete_types: if x.type in discrete_types: return [x.zeros_like(dtype=theano.config.floatX)] else: return [x.zeros_like()] cst = np.asarray(2. / np.sqrt(np.pi), dtype=upcast(x.type.dtype, gz.type.dtype)) return - gz * cst * exp(-x * x),
def L_op(self, inputs, outputs, grads): x, = inputs gz, = grads if x.type in complex_types: raise NotImplementedError() if outputs[0].type in discrete_types: if x.type in discrete_types: return [x.zeros_like(dtype=theano.config.floatX)] else: return [x.zeros_like()] cst = numpy.asarray(numpy.sqrt(numpy.pi) / 2., dtype=upcast(x.type.dtype, gz.type.dtype)) return gz * cst * exp(erfinv(x) ** 2),
def L_op(self, inputs, outputs, grads): (x, ) = inputs (gz, ) = grads if x.type in complex_types: raise NotImplementedError() if outputs[0].type in discrete_types: if x.type in discrete_types: return [x.zeros_like(dtype=config.floatX)] else: return [x.zeros_like()] cst = np.asarray(2.0 / np.sqrt(np.pi), dtype=upcast(x.type.dtype, gz.type.dtype)) return (-gz * cst * exp(-x * x), )
def grad(self, inputs, gout): (x,) = inputs (gz,) = gout return [gz *sgn_pg2_alpha * exp(-sgn_pg2_beta * abs(x))]