Пример #1
0
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)),
Пример #2
0
 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,)
Пример #3
0
 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,
Пример #4
0
    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),)
Пример #5
0
    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. / numpy.sqrt(numpy.pi),
                            dtype=upcast(x.type.dtype, gz.type.dtype))
        return gz * cst * exp(-x * x),
Пример #6
0
    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),
Пример #7
0
    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),
Пример #8
0
    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.0,
                         dtype=upcast(x.type.dtype, gz.type.dtype))
        return (-gz * cst * exp(erfcinv(x)**2), )
Пример #9
0
    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 + (2. * x) * erfcx(x)),
Пример #10
0
    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),
Пример #11
0
    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 + (2.0 * x) * erfcx(x)), )
Пример #12
0
    grad_rtol=div_grad_rtol,
    inplace=True,
)

TestInvInplaceBroadcast = makeBroadcastTester(
    op=inv_inplace,
    expected=lambda x: _numpy_true_div(np.int8(1), x),
    good=_good_inv_inplace,
    bad_runtime=_bad_runtime_inv,
    grad_rtol=div_grad_rtol,
    inplace=True,
)

TestModInplaceBroadcast = makeBroadcastTester(
    op=mod_inplace,
    expected=lambda x, y: np.asarray(x % y, dtype=upcast(x.dtype, y.dtype)),
    good=copymod(_good_broadcast_div_mod_normal_float_inplace,
                 ["complex1", "complex2"]),
    grad_eps=1e-5,
    inplace=True,
)

TestPowInplaceBroadcast = makeBroadcastTester(
    op=pow_inplace,
    expected=lambda x, y: x**y,
    good=_good_broadcast_pow_normal_float_pow,
    inplace=True,
    mode=ignore_isfinite_mode,
)

TestNegInplaceBroadcast = makeBroadcastTester(