提交 426686fe authored 作者: ebuchman's avatar ebuchman

Merge pull request #1 from nouiz/ebuchman-chi2sf/master

Finish chi2 tests and GPU code.
...@@ -289,6 +289,7 @@ DEVICE double _psi(double x){ ...@@ -289,6 +289,7 @@ DEVICE double _psi(double x){
return hash(type(self)) return hash(type(self))
psi = Psi(upgrade_to_float, name='psi') psi = Psi(upgrade_to_float, name='psi')
class Chi2SF(BinaryScalarOp): class Chi2SF(BinaryScalarOp):
""" """
Compute (1 - chi2_cdf(x)) Compute (1 - chi2_cdf(x))
...@@ -298,11 +299,13 @@ class Chi2SF(BinaryScalarOp): ...@@ -298,11 +299,13 @@ class Chi2SF(BinaryScalarOp):
@staticmethod @staticmethod
def st_impl(x, k): def st_impl(x, k):
return scipy.stats.chi2.sf(x, k) return scipy.stats.chi2.sf(x, k)
def impl(self, x, k): def impl(self, x, k):
if imported_scipy_special: if imported_scipy_special:
return Chi2SF.st_impl(x, k) return Chi2SF.st_impl(x, k)
else: else:
super(Chi2SF, self).impl(x, k) super(Chi2SF, self).impl(x, k)
def c_support_code(self): def c_support_code(self):
return( return(
""" """
...@@ -350,15 +353,15 @@ class Chi2SF(BinaryScalarOp): ...@@ -350,15 +353,15 @@ class Chi2SF(BinaryScalarOp):
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
Table of Factorials/Gamma Values Table of Factorials/Gamma Values
----------------------------------------------------------------------*/ ----------------------------------------------------------------------*/
static double _facts[MAXFACT+1] = { 0 }; DEVICE static double _facts[MAXFACT+1] = { 0 };
static double _logfs[MAXFACT+1]; DEVICE static double _logfs[MAXFACT+1];
static double _halfs[MAXFACT+1]; DEVICE static double _halfs[MAXFACT+1];
static double _loghs[MAXFACT+1]; DEVICE static double _loghs[MAXFACT+1];
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
Functions Functions
----------------------------------------------------------------------*/ ----------------------------------------------------------------------*/
static void _init (void) DEVICE static void _init (void)
{ /* --- init. factorial tables */ { /* --- init. factorial tables */
int i; /* loop variable */ int i; /* loop variable */
double x = 1; /* factorial */ double x = 1; /* factorial */
...@@ -404,7 +407,7 @@ class Chi2SF(BinaryScalarOp): ...@@ -404,7 +407,7 @@ class Chi2SF(BinaryScalarOp):
#else /*--------------------------------------------------------------*/ #else /*--------------------------------------------------------------*/
double logGamma (double n) DEVICE double logGamma (double n)
{ /* --- compute ln(Gamma(n)) */ { /* --- compute ln(Gamma(n)) */
double s; /* = ln((n-1)!), n \in IN */ double s; /* = ln((n-1)!), n \in IN */
...@@ -450,7 +453,7 @@ class Chi2SF(BinaryScalarOp): ...@@ -450,7 +453,7 @@ class Chi2SF(BinaryScalarOp):
in the second version, the value is slightly more accurate. in the second version, the value is slightly more accurate.
----------------------------------------------------------------------*/ ----------------------------------------------------------------------*/
double Gamma (double n) DEVICE double Gamma (double n)
{ /* --- compute Gamma(n) = (n-1)! */ { /* --- compute Gamma(n) = (n-1)! */
assert(n > 0); /* check the function argument */ assert(n > 0); /* check the function argument */
if (_facts[0] <= 0) _init(); /* initialize the tables */ if (_facts[0] <= 0) _init(); /* initialize the tables */
...@@ -465,7 +468,7 @@ class Chi2SF(BinaryScalarOp): ...@@ -465,7 +468,7 @@ class Chi2SF(BinaryScalarOp):
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static double _series (double n, double x) DEVICE static double _series (double n, double x)
{ /* --- series approximation */ { /* --- series approximation */
int i; /* loop variable */ int i; /* loop variable */
double t, sum; /* buffers */ double t, sum; /* buffers */
...@@ -491,7 +494,7 @@ class Chi2SF(BinaryScalarOp): ...@@ -491,7 +494,7 @@ class Chi2SF(BinaryScalarOp):
The factor exp(n *log(x) -x) is added in the functions below. The factor exp(n *log(x) -x) is added in the functions below.
----------------------------------------------------------------------*/ ----------------------------------------------------------------------*/
static double _cfrac (double n, double x) DEVICE static double _cfrac (double n, double x)
{ /* --- continued fraction approx. */ { /* --- continued fraction approx. */
int i; /* loop variable */ int i; /* loop variable */
double a, b, c, d, e, f; /* buffers */ double a, b, c, d, e, f; /* buffers */
...@@ -523,7 +526,7 @@ class Chi2SF(BinaryScalarOp): ...@@ -523,7 +526,7 @@ class Chi2SF(BinaryScalarOp):
The factor exp(n *log(x) -x) is added in the functions below. The factor exp(n *log(x) -x) is added in the functions below.
----------------------------------------------------------------------*/ ----------------------------------------------------------------------*/
double lowerGamma (double n, double x) DEVICE double lowerGamma (double n, double x)
{ /* --- lower incomplete Gamma fn. */ { /* --- lower incomplete Gamma fn. */
assert((n > 0) && (x > 0)); /* check the function arguments */ assert((n > 0) && (x > 0)); /* check the function arguments */
return _series(n, x) *exp(n *log(x) -x); return _series(n, x) *exp(n *log(x) -x);
...@@ -531,7 +534,7 @@ class Chi2SF(BinaryScalarOp): ...@@ -531,7 +534,7 @@ class Chi2SF(BinaryScalarOp):
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
double upperGamma (double n, double x) DEVICE double upperGamma (double n, double x)
{ /* --- upper incomplete Gamma fn. */ { /* --- upper incomplete Gamma fn. */
assert((n > 0) && (x > 0)); /* check the function arguments */ assert((n > 0) && (x > 0)); /* check the function arguments */
return _cfrac(n, x) *exp(n *log(x) -x); return _cfrac(n, x) *exp(n *log(x) -x);
...@@ -539,8 +542,7 @@ class Chi2SF(BinaryScalarOp): ...@@ -539,8 +542,7 @@ class Chi2SF(BinaryScalarOp):
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
DEVICE double GammaP (double n, double x)
double GammaP (double n, double x)
{ /* --- regularized Gamma function P */ { /* --- regularized Gamma function P */
assert((n > 0) && (x >= 0)); /* check the function arguments */ assert((n > 0) && (x >= 0)); /* check the function arguments */
if (x <= 0) return 0; /* treat x = 0 as a special case */ if (x <= 0) return 0; /* treat x = 0 as a special case */
...@@ -555,21 +557,21 @@ class Chi2SF(BinaryScalarOp): ...@@ -555,21 +557,21 @@ class Chi2SF(BinaryScalarOp):
{ {
return 1 - GammaP(k/2., x/2.); return 1 - GammaP(k/2., x/2.);
} }
#endif
""") """)
def c_code(self, node, name, inp, out, sub): def c_code(self, node, name, inp, out, sub):
x, k = inp x, k = inp
z, = out z, = out
if node.inputs[0].type in float_types: if node.inputs[0].type in float_types:
dtype = z.dtype dtype = 'npy_' + node.outputs[0].dtype
return """%(z)s = return """%(z)s =
(%(dtype)s)Chi2SF(%(k)s, %(x)s);""" % locals() (%(dtype)s)Chi2SF(%(k)s, %(x)s);""" % locals()
raise NotImplementedError('only floatingpoint is implemented') raise NotImplementedError('only floatingpoint is implemented')
def __eq__(self, other): def __eq__(self, other):
return type(self) == type(other) return type(self) == type(other)
def __hash__(self): def __hash__(self):
return hash(type(self)) return hash(type(self))
......
...@@ -69,14 +69,15 @@ utt.seed_rng() ...@@ -69,14 +69,15 @@ utt.seed_rng()
def inplace_func(inputs, outputs, mode=None, allow_input_downcast=False, def inplace_func(inputs, outputs, mode=None, allow_input_downcast=False,
on_unused_input='raise'): on_unused_input='raise', name=None):
if mode is None: if mode is None:
mode = get_default_mode() mode = get_default_mode()
return function(inputs, outputs, return function(inputs, outputs,
mode=mode, mode=mode,
allow_input_downcast=allow_input_downcast, allow_input_downcast=allow_input_downcast,
accept_inplace=True, accept_inplace=True,
on_unused_input=on_unused_input) on_unused_input=on_unused_input,
name=name)
def eval_outputs(outputs): def eval_outputs(outputs):
...@@ -292,7 +293,7 @@ def makeTester(name, op, expected, checks=None, good=None, bad_build=None, ...@@ -292,7 +293,7 @@ def makeTester(name, op, expected, checks=None, good=None, bad_build=None,
raise raise
try: try:
f = inplace_func(inputrs, node.outputs, mode=mode) f = inplace_func(inputrs, node.outputs, mode=mode, name='test_good')
except Exception, exc: except Exception, exc:
err_msg = ("Test %s::%s: Error occurred while" err_msg = ("Test %s::%s: Error occurred while"
" trying to make a Function") % (self.op, testname) " trying to make a Function") % (self.op, testname)
...@@ -382,7 +383,7 @@ def makeTester(name, op, expected, checks=None, good=None, bad_build=None, ...@@ -382,7 +383,7 @@ def makeTester(name, op, expected, checks=None, good=None, bad_build=None,
raise raise
try: try:
f = inplace_func([], node.outputs, mode=mode) f = inplace_func([], node.outputs, mode=mode, name="test_bad_runtime")
except Exception, exc: except Exception, exc:
err_msg = ("Test %s::%s: Error occurred while trying" err_msg = ("Test %s::%s: Error occurred while trying"
" to make a Function") % (self.op, testname) " to make a Function") % (self.op, testname)
...@@ -536,7 +537,8 @@ _good_broadcast_binary_normal = dict( ...@@ -536,7 +537,8 @@ _good_broadcast_binary_normal = dict(
# Disabled as we test the case where we reuse the same output as the # Disabled as we test the case where we reuse the same output as the
# first inputs. # first inputs.
# complex3=(rand(2,3),randcomplex(2,3)), # complex3=(rand(2,3),randcomplex(2,3)),
empty=(numpy.asarray([]), numpy.asarray([1])), empty=(numpy.asarray([], dtype=config.floatX),
numpy.asarray([1], dtype=config.floatX)),
) )
_bad_build_broadcast_binary_normal = dict() _bad_build_broadcast_binary_normal = dict()
...@@ -740,7 +742,8 @@ if PY3: ...@@ -740,7 +742,8 @@ if PY3:
else: else:
_good_broadcast_div_mod_normal_float_inplace = copymod( _good_broadcast_div_mod_normal_float_inplace = copymod(
_good_broadcast_div_mod_normal_float_no_complex, _good_broadcast_div_mod_normal_float_no_complex,
empty1=(numpy.asarray([]), numpy.asarray([1])), empty1=(numpy.asarray([], dtype=config.floatX),
numpy.asarray([1], dtype=config.floatX)),
complex1=(randcomplex(2, 3), randcomplex_nonzero((2, 3))), complex1=(randcomplex(2, 3), randcomplex_nonzero((2, 3))),
complex2=(randcomplex(2, 3), rand_nonzero((2, 3))), complex2=(randcomplex(2, 3), rand_nonzero((2, 3))),
# Inplace on the first element. Must have the same type. # Inplace on the first element. Must have the same type.
...@@ -749,7 +752,8 @@ else: ...@@ -749,7 +752,8 @@ else:
_good_broadcast_div_mod_normal_float = copymod( _good_broadcast_div_mod_normal_float = copymod(
_good_broadcast_div_mod_normal_float_inplace, _good_broadcast_div_mod_normal_float_inplace,
empty2=(numpy.asarray([0]), numpy.asarray([])) empty2=(numpy.asarray([0], dtype=config.floatX),
numpy.asarray([], dtype=config.floatX))
) )
...@@ -842,8 +846,13 @@ _good_broadcast_pow_normal_float = dict(same_shapes = (rand_ranged(1, 5, (2, 3)) ...@@ -842,8 +846,13 @@ _good_broadcast_pow_normal_float = dict(same_shapes = (rand_ranged(1, 5, (2, 3))
complex1 = (randcomplex(2,3),randcomplex(2,3)), complex1 = (randcomplex(2,3),randcomplex(2,3)),
complex2 = (randcomplex(2,3),rand(2,3)), complex2 = (randcomplex(2,3),rand(2,3)),
#complex3 = (rand(2,3),randcomplex(2,3)), # Inplace on the first element. #complex3 = (rand(2,3),randcomplex(2,3)), # Inplace on the first element.
empty1 = (numpy.asarray([]), numpy.asarray([1])), empty1 = (numpy.asarray([], dtype=config.floatX),
empty2 = (numpy.asarray([0]), numpy.asarray([])),) numpy.asarray([1], dtype=config.floatX)),
empty2 = (numpy.asarray([0], dtype=config.floatX),
numpy.asarray([], dtype=config.floatX)),
empty3 = (numpy.asarray([], dtype=config.floatX),
numpy.asarray([], dtype=config.floatX)),
)
_grad_broadcast_pow_normal = dict(same_shapes = (rand_ranged(1, 5, (2, 3)), rand_ranged(-3, 3, (2, 3))), _grad_broadcast_pow_normal = dict(same_shapes = (rand_ranged(1, 5, (2, 3)), rand_ranged(-3, 3, (2, 3))),
scalar = (rand_ranged(1, 5, (2, 3)), rand_ranged(-3, 3, (1, 1))), scalar = (rand_ranged(1, 5, (2, 3)), rand_ranged(-3, 3, (1, 1))),
row = ( row = (
...@@ -889,7 +898,7 @@ _good_broadcast_unary_normal_float = dict( ...@@ -889,7 +898,7 @@ _good_broadcast_unary_normal_float = dict(
normal=[rand_ranged(-5, 5, (2, 3))], normal=[rand_ranged(-5, 5, (2, 3))],
corner_case=[corner_case], corner_case=[corner_case],
complex=[randcomplex(2, 3)], complex=[randcomplex(2, 3)],
empty=[numpy.asarray([])]) empty=[numpy.asarray([], dtype=config.floatX)])
_good_broadcast_unary_normal_float_no_empty = copymod( _good_broadcast_unary_normal_float_no_empty = copymod(
_good_broadcast_unary_normal_float, _good_broadcast_unary_normal_float,
...@@ -909,14 +918,14 @@ _good_broadcast_unary_normal = dict( ...@@ -909,14 +918,14 @@ _good_broadcast_unary_normal = dict(
integers=[randint_ranged(-5, 5, (2, 3))], integers=[randint_ranged(-5, 5, (2, 3))],
corner_case=[corner_case], corner_case=[corner_case],
complex=[randcomplex(2, 3)], complex=[randcomplex(2, 3)],
empty=[numpy.asarray([])], empty=[numpy.asarray([], dtype=config.floatX)],
) )
_good_broadcast_unary_normal_no_complex = dict( _good_broadcast_unary_normal_no_complex = dict(
normal=[numpy.asarray(rand_ranged(-5, 5, (2, 3)), dtype=floatX)], normal=[numpy.asarray(rand_ranged(-5, 5, (2, 3)), dtype=floatX)],
integers=[randint_ranged(-5, 5, (2, 3))], integers=[randint_ranged(-5, 5, (2, 3))],
corner_case=[corner_case], corner_case=[corner_case],
empty=[numpy.asarray([])], empty=[numpy.asarray([], dtype=config.floatX)],
) )
_grad_broadcast_unary_normal_no_complex = dict( _grad_broadcast_unary_normal_no_complex = dict(
...@@ -1123,7 +1132,7 @@ Expm1InplaceTester = makeBroadcastTester(op=inplace.expm1_inplace, ...@@ -1123,7 +1132,7 @@ Expm1InplaceTester = makeBroadcastTester(op=inplace.expm1_inplace,
_good_broadcast_unary_positive = dict(normal=(rand_ranged(0.001, 5, (2, 3)),), _good_broadcast_unary_positive = dict(normal=(rand_ranged(0.001, 5, (2, 3)),),
integers=(randint_ranged(1, 5, (2, 3)),), integers=(randint_ranged(1, 5, (2, 3)),),
complex=(randc128_ranged(1, 5, (2, 3)),), complex=(randc128_ranged(1, 5, (2, 3)),),
empty=(numpy.asarray([]),), empty=(numpy.asarray([], dtype=config.floatX),),
) )
_grad_broadcast_unary_positive = dict(normal=(rand_ranged(0.001, 5, (2, 3)),),) _grad_broadcast_unary_positive = dict(normal=(rand_ranged(0.001, 5, (2, 3)),),)
...@@ -1182,7 +1191,7 @@ _good_broadcast_unary_wide = dict( ...@@ -1182,7 +1191,7 @@ _good_broadcast_unary_wide = dict(
normal=(rand_ranged(-1000, 1000, (2, 3)),), normal=(rand_ranged(-1000, 1000, (2, 3)),),
integers=(randint_ranged(-1000, 1000, (2, 3)),), integers=(randint_ranged(-1000, 1000, (2, 3)),),
complex=(randc128_ranged(-1000, 1000, (2, 3)),), complex=(randc128_ranged(-1000, 1000, (2, 3)),),
empty=(numpy.asarray([]),),) empty=(numpy.asarray([], dtype=config.floatX),),)
_grad_broadcast_unary_wide = dict(normal=(rand_ranged(-1000, 1000, (2, 3)),),) _grad_broadcast_unary_wide = dict(normal=(rand_ranged(-1000, 1000, (2, 3)),),)
if theano.config.floatX == 'float32': if theano.config.floatX == 'float32':
...@@ -1231,7 +1240,7 @@ SinInplaceTester = makeBroadcastTester(op=inplace.sin_inplace, ...@@ -1231,7 +1240,7 @@ SinInplaceTester = makeBroadcastTester(op=inplace.sin_inplace,
_good_broadcast_unary_arcsin = dict(normal=(rand_ranged(-1, 1, (2, 3)),), _good_broadcast_unary_arcsin = dict(normal=(rand_ranged(-1, 1, (2, 3)),),
integers=(randint_ranged(-1, 1, (2, 3)),), integers=(randint_ranged(-1, 1, (2, 3)),),
complex=(randc128_ranged(-1, 1, (2, 3)),), complex=(randc128_ranged(-1, 1, (2, 3)),),
empty=(numpy.asarray([]),),) empty=(numpy.asarray([], dtype=config.floatX),),)
_grad_broadcast_unary_arcsin = dict(normal=(rand_ranged(-1, 1, (2, 3)),),) _grad_broadcast_unary_arcsin = dict(normal=(rand_ranged(-1, 1, (2, 3)),),)
ArcsinTester = makeBroadcastTester(op=tensor.arcsin, ArcsinTester = makeBroadcastTester(op=tensor.arcsin,
...@@ -1269,7 +1278,7 @@ _good_broadcast_unary_tan = dict( ...@@ -1269,7 +1278,7 @@ _good_broadcast_unary_tan = dict(
shifted=(rand_ranged(3.15, 6.28, (2, 3)),), shifted=(rand_ranged(3.15, 6.28, (2, 3)),),
integers=(randint_ranged(-3, 3, (2, 3)),), integers=(randint_ranged(-3, 3, (2, 3)),),
complex=(randc128_ranged(-3.14, 3.14, (2, 3)),), complex=(randc128_ranged(-3.14, 3.14, (2, 3)),),
empty=(numpy.asarray([]),),) empty=(numpy.asarray([], dtype=config.floatX),),)
#We do not want to test around the discontinuity. #We do not want to test around the discontinuity.
_grad_broadcast_unary_tan = dict(normal=(rand_ranged(-1.5, 1.5, (2, 3)),), _grad_broadcast_unary_tan = dict(normal=(rand_ranged(-1.5, 1.5, (2, 3)),),
shifted=(rand_ranged(1.6, 4.6, (2, 3)),)) shifted=(rand_ranged(1.6, 4.6, (2, 3)),))
...@@ -1304,7 +1313,8 @@ _good_broadcast_binary_arctan2 = dict( ...@@ -1304,7 +1313,8 @@ _good_broadcast_binary_arctan2 = dict(
integers=(randint(2, 3), randint(2, 3)), integers=(randint(2, 3), randint(2, 3)),
dtype_mixup_1=(rand(2, 3), randint(2, 3)), dtype_mixup_1=(rand(2, 3), randint(2, 3)),
dtype_mixup_2=(randint(2, 3), rand(2, 3)), dtype_mixup_2=(randint(2, 3), rand(2, 3)),
empty=(numpy.asarray([]), numpy.asarray([1])), empty=(numpy.asarray([], dtype=config.floatX),
numpy.asarray([1], dtype=config.floatX)),
) )
_grad_broadcast_binary_arctan2 = dict( _grad_broadcast_binary_arctan2 = dict(
...@@ -1338,7 +1348,7 @@ _good_broadcast_unary_arccosh = dict( ...@@ -1338,7 +1348,7 @@ _good_broadcast_unary_arccosh = dict(
normal=(rand_ranged(1, 1000, (2, 3)),), normal=(rand_ranged(1, 1000, (2, 3)),),
integers=(randint_ranged(1, 1000, (2, 3)),), integers=(randint_ranged(1, 1000, (2, 3)),),
complex=(randc128_ranged(1, 1000, (2, 3)),), complex=(randc128_ranged(1, 1000, (2, 3)),),
empty=(numpy.asarray([]),),) empty=(numpy.asarray([], dtype=config.floatX),),)
_grad_broadcast_unary_arccosh = dict(normal=(rand_ranged(1, 1000, (2, 3)),),) _grad_broadcast_unary_arccosh = dict(normal=(rand_ranged(1, 1000, (2, 3)),),)
ArccoshTester = makeBroadcastTester(op=tensor.arccosh, ArccoshTester = makeBroadcastTester(op=tensor.arccosh,
...@@ -1386,7 +1396,7 @@ _good_broadcast_unary_arctanh = dict( ...@@ -1386,7 +1396,7 @@ _good_broadcast_unary_arctanh = dict(
normal=(rand_ranged(-1 + _eps, 1 - _eps, (2, 3)),), normal=(rand_ranged(-1 + _eps, 1 - _eps, (2, 3)),),
integers=(randint_ranged(-1 + _eps, 1 - _eps, (2, 3)),), integers=(randint_ranged(-1 + _eps, 1 - _eps, (2, 3)),),
complex=(randc128_ranged(-1 + _eps, 1 - _eps, (2, 3)),), complex=(randc128_ranged(-1 + _eps, 1 - _eps, (2, 3)),),
empty=(numpy.asarray([]),),) empty=(numpy.asarray([], dtype=config.floatX),),)
_grad_broadcast_unary_arctanh = dict( _grad_broadcast_unary_arctanh = dict(
normal=(rand_ranged(-1 + _eps, 1 - _eps, (2, 3)),),) normal=(rand_ranged(-1 + _eps, 1 - _eps, (2, 3)),),)
...@@ -1420,7 +1430,7 @@ if imported_scipy_special: ...@@ -1420,7 +1430,7 @@ if imported_scipy_special:
expected_gamma = scipy.special.gamma expected_gamma = scipy.special.gamma
expected_gammaln = scipy.special.gammaln expected_gammaln = scipy.special.gammaln
expected_psi = scipy.special.psi expected_psi = scipy.special.psi
expected_chi2sf = scipy.stats.chi2.sf expected_chi2sf = lambda x, df: scipy.stats.chi2.sf(x, df).astype(x.dtype)
skip_scipy = False skip_scipy = False
else: else:
expected_erf = [] expected_erf = []
...@@ -1489,7 +1499,7 @@ ErfcinvTester = makeBroadcastTester( ...@@ -1489,7 +1499,7 @@ ErfcinvTester = makeBroadcastTester(
_good_broadcast_unary_gammaln = dict( _good_broadcast_unary_gammaln = dict(
normal=(rand_ranged(-1 + 1e-2, 10, (2, 3)),), normal=(rand_ranged(-1 + 1e-2, 10, (2, 3)),),
empty=(numpy.asarray([]),),) empty=(numpy.asarray([], dtype=config.floatX),),)
_grad_broadcast_unary_gammaln = dict( _grad_broadcast_unary_gammaln = dict(
# smaller range as our grad method does not estimate it well enough. # smaller range as our grad method does not estimate it well enough.
normal=(rand_ranged(1e-8, 8, (2, 3)),),) normal=(rand_ranged(1e-8, 8, (2, 3)),),)
...@@ -1532,7 +1542,7 @@ GammalnInplaceTester = makeBroadcastTester( ...@@ -1532,7 +1542,7 @@ GammalnInplaceTester = makeBroadcastTester(
_good_broadcast_unary_psi = dict( _good_broadcast_unary_psi = dict(
normal=(rand_ranged(1, 10, (2, 3)),), normal=(rand_ranged(1, 10, (2, 3)),),
empty=(numpy.asarray([]),),) empty=(numpy.asarray([], dtype=config.floatX),),)
PsiTester = makeBroadcastTester( PsiTester = makeBroadcastTester(
op=tensor.psi, op=tensor.psi,
...@@ -1551,13 +1561,13 @@ PsiInplaceTester = makeBroadcastTester( ...@@ -1551,13 +1561,13 @@ PsiInplaceTester = makeBroadcastTester(
skip=skip_scipy) skip=skip_scipy)
'''
#chi2sf takes two inputs, a value (x) and a degrees of freedom (k). #chi2sf takes two inputs, a value (x) and a degrees of freedom (k).
# not sure how to deal with that here... # not sure how to deal with that here...
_good_broadcast_unary_chi2sf = dict( _good_broadcast_unary_chi2sf = dict(
normal=(rand_ranged(1, 10, (2, 3)),), normal=(rand_ranged(1, 10, (2, 3)), numpy.asarray(1, dtype=config.floatX)),
empty=(numpy.asarray([]),),) empty=(numpy.asarray([], dtype=config.floatX),
numpy.asarray(1, dtype=config.floatX)))
Chi2SFTester = makeBroadcastTester( Chi2SFTester = makeBroadcastTester(
op=tensor.chi2sf, op=tensor.chi2sf,
...@@ -1565,7 +1575,8 @@ Chi2SFTester = makeBroadcastTester( ...@@ -1565,7 +1575,8 @@ Chi2SFTester = makeBroadcastTester(
good=_good_broadcast_unary_chi2sf, good=_good_broadcast_unary_chi2sf,
eps=2e-10, eps=2e-10,
mode=mode_no_scipy, mode=mode_no_scipy,
skip=skip_scipy) skip=skip_scipy,
name='Chi2SF')
Chi2SFInplaceTester = makeBroadcastTester( Chi2SFInplaceTester = makeBroadcastTester(
op=inplace.chi2sf_inplace, op=inplace.chi2sf_inplace,
expected=expected_chi2sf, expected=expected_chi2sf,
...@@ -1573,8 +1584,8 @@ Chi2SFInplaceTester = makeBroadcastTester( ...@@ -1573,8 +1584,8 @@ Chi2SFInplaceTester = makeBroadcastTester(
eps=2e-10, eps=2e-10,
mode=mode_no_scipy, mode=mode_no_scipy,
inplace=True, inplace=True,
skip=skip_scipy) skip=skip_scipy,
''' name='Chi2SF')
ZerosLikeTester = makeBroadcastTester( ZerosLikeTester = makeBroadcastTester(
op=tensor.zeros_like, op=tensor.zeros_like,
...@@ -1598,7 +1609,8 @@ _good_complex_from_polar = dict( ...@@ -1598,7 +1609,8 @@ _good_complex_from_polar = dict(
row=(abs(rand(2, 3)), rand(1, 3)), row=(abs(rand(2, 3)), rand(1, 3)),
column=(abs(rand(2, 3)), rand(2, 1)), column=(abs(rand(2, 3)), rand(2, 1)),
integers=(abs(randint(2, 3)), randint(2, 3)), integers=(abs(randint(2, 3)), randint(2, 3)),
empty=(numpy.asarray([]), numpy.asarray([1])),) empty=(numpy.asarray([], dtype=config.floatX),
numpy.asarray([1], dtype=config.floatX)),)
_grad_complex_from_polar = dict( _grad_complex_from_polar = dict(
same_shapes=(abs(rand(2, 3)), rand(2, 3)), same_shapes=(abs(rand(2, 3)), rand(2, 3)),
scalar=(abs(rand(2, 3)), rand(1, 1)), scalar=(abs(rand(2, 3)), rand(1, 1)),
...@@ -1637,8 +1649,8 @@ DotTester = makeTester(name='DotTester', ...@@ -1637,8 +1649,8 @@ DotTester = makeTester(name='DotTester',
randcomplex(7)), randcomplex(7)),
complex2=(rand(5, 7), randcomplex(7)), complex2=(rand(5, 7), randcomplex(7)),
complex3=(randcomplex(5, 7), rand(7)), complex3=(randcomplex(5, 7), rand(7)),
empty1=(numpy.asarray([]), empty1=(numpy.asarray([], dtype=config.floatX),
numpy.asarray([])), numpy.asarray([], dtype=config.floatX)),
empty2=(rand(5, 0), rand(0, 2)), empty2=(rand(5, 0), rand(0, 2)),
empty3=(rand(0, 5), rand(5, 0)), empty3=(rand(0, 5), rand(5, 0)),
), ),
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论