提交 c5da9237 authored 作者: Frédéric Bastien's avatar Frédéric Bastien 提交者: GitHub

Merge pull request #4726 from abergeron/fix_buildbot

Fix some problems in the buildbot
...@@ -18,6 +18,8 @@ from theano.compat import PY3 ...@@ -18,6 +18,8 @@ from theano.compat import PY3
from theano import config from theano import config
from theano.misc.pkl_utils import CompatUnpickler from theano.misc.pkl_utils import CompatUnpickler
from ..type import ContextNotDefined
try: try:
from . import config as _ # noqa from . import config as _ # noqa
have_pygpu = True have_pygpu = True
...@@ -26,11 +28,9 @@ except SkipTest: ...@@ -26,11 +28,9 @@ except SkipTest:
def test_unpickle_gpuarray_as_numpy_ndarray_flag1(): def test_unpickle_gpuarray_as_numpy_ndarray_flag1():
"""Only test when pygpu isn't # Only test when pygpu isn't
available. test_unpickle_gpuarray_as_numpy_ndarray_flag0 in # available. test_unpickle_gpuarray_as_numpy_ndarray_flag0 in
test_type.py test it when pygpu is there. # test_type.py test it when pygpu is there.
"""
if have_pygpu: if have_pygpu:
raise SkipTest("pygpu active") raise SkipTest("pygpu active")
oldflag = config.experimental.unpickle_gpu_on_cpu oldflag = config.experimental.unpickle_gpu_on_cpu
...@@ -45,7 +45,7 @@ def test_unpickle_gpuarray_as_numpy_ndarray_flag1(): ...@@ -45,7 +45,7 @@ def test_unpickle_gpuarray_as_numpy_ndarray_flag1():
u = CompatUnpickler(fp, encoding="latin1") u = CompatUnpickler(fp, encoding="latin1")
else: else:
u = CompatUnpickler(fp) u = CompatUnpickler(fp)
assert_raises(ImportError, u.load) assert_raises((ImportError, ContextNotDefined), u.load)
finally: finally:
config.experimental.unpickle_gpu_on_cpu = oldflag config.experimental.unpickle_gpu_on_cpu = oldflag
......
...@@ -723,7 +723,7 @@ def test_batchnorm_train(): ...@@ -723,7 +723,7 @@ def test_batchnorm_train():
utt.seed_rng() utt.seed_rng()
for mode in ('per-activation', 'spatial'): for mode in ('per-activation', 'spatial'):
for vartype in (T.tensor4, T.tensor3, T.matrix, T.vector): for vartype in (T.ftensor4, T.ftensor3, T.fmatrix, T.fvector):
x, scale, bias = (vartype(n) for n in ('x', 'scale', 'bias')) x, scale, bias = (vartype(n) for n in ('x', 'scale', 'bias'))
ndim = x.ndim ndim = x.ndim
eps = 5e-3 # some non-standard value to test if it's used eps = 5e-3 # some non-standard value to test if it's used
...@@ -751,15 +751,14 @@ def test_batchnorm_train(): ...@@ -751,15 +751,14 @@ def test_batchnorm_train():
[out, x_mean, x_invstd, out2, x_mean2, x_invstd2] + [out, x_mean, x_invstd, out2, x_mean2, x_invstd2] +
grads + grads2, mode=mode_with_gpu) grads + grads2, mode=mode_with_gpu)
# run # run
floatX = theano.config.floatX
for data_shape in ((10, 20, 30, 40), (4, 3, 1, 1), (1, 1, 5, 5)): for data_shape in ((10, 20, 30, 40), (4, 3, 1, 1), (1, 1, 5, 5)):
data_shape = data_shape[:ndim] data_shape = data_shape[:ndim]
param_shape = tuple(1 if d in axes else s param_shape = tuple(1 if d in axes else s
for d, s in enumerate(data_shape)) for d, s in enumerate(data_shape))
X = 4 + 3 * numpy.random.randn(*data_shape).astype(floatX) X = 4 + 3 * numpy.random.randn(*data_shape).astype('float32')
Dy = -1 + 2 * numpy.random.randn(*data_shape).astype(floatX) Dy = -1 + 2 * numpy.random.randn(*data_shape).astype('float32')
Scale = numpy.random.randn(*param_shape).astype(floatX) Scale = numpy.random.randn(*param_shape).astype('float32')
Bias = numpy.random.randn(*param_shape).astype(floatX) Bias = numpy.random.randn(*param_shape).astype('float32')
outputs = f(X, Scale, Bias, Dy) outputs = f(X, Scale, Bias, Dy)
# compare outputs # compare outputs
utt.assert_allclose(outputs[0], outputs[0 + 3]) # out utt.assert_allclose(outputs[0], outputs[0 + 3]) # out
...@@ -779,7 +778,7 @@ def test_batchnorm_inference(): ...@@ -779,7 +778,7 @@ def test_batchnorm_inference():
utt.seed_rng() utt.seed_rng()
for mode in ('per-activation', 'spatial'): for mode in ('per-activation', 'spatial'):
for vartype in (T.tensor4, T.tensor3, T.matrix, T.vector): for vartype in (T.ftensor4, T.ftensor3, T.fmatrix, T.fvector):
x, scale, bias, mean, var = (vartype(n) for n in ('x', 'scale', x, scale, bias, mean, var = (vartype(n) for n in ('x', 'scale',
'bias', 'mean', 'bias', 'mean',
'var')) 'var'))
...@@ -806,17 +805,16 @@ def test_batchnorm_inference(): ...@@ -806,17 +805,16 @@ def test_batchnorm_inference():
f = theano.function([x, scale, bias, mean, var, dy], f = theano.function([x, scale, bias, mean, var, dy],
[out, out2] + grads + grads2, mode=mode_with_gpu) [out, out2] + grads + grads2, mode=mode_with_gpu)
# run # run
floatX = theano.config.floatX
for data_shape in ((10, 20, 30, 40), (4, 3, 1, 1), (1, 1, 5, 5)): for data_shape in ((10, 20, 30, 40), (4, 3, 1, 1), (1, 1, 5, 5)):
data_shape = data_shape[:ndim] data_shape = data_shape[:ndim]
param_shape = tuple(1 if d in axes else s param_shape = tuple(1 if d in axes else s
for d, s in enumerate(data_shape)) for d, s in enumerate(data_shape))
X = 4 + 3 * numpy.random.randn(*data_shape).astype(floatX) X = 4 + 3 * numpy.random.randn(*data_shape).astype('float32')
Dy = -1 + 2 * numpy.random.randn(*data_shape).astype(floatX) Dy = -1 + 2 * numpy.random.randn(*data_shape).astype('float32')
Scale = numpy.random.randn(*param_shape).astype(floatX) Scale = numpy.random.randn(*param_shape).astype('float32')
Bias = numpy.random.randn(*param_shape).astype(floatX) Bias = numpy.random.randn(*param_shape).astype('float32')
Mean = numpy.random.randn(*param_shape).astype(floatX) Mean = numpy.random.randn(*param_shape).astype('float32')
Var = numpy.random.rand(*param_shape).astype(floatX) Var = numpy.random.rand(*param_shape).astype('float32')
outputs = f(X, Scale, Bias, Mean, Var, Dy) outputs = f(X, Scale, Bias, Mean, Var, Dy)
# compare outputs # compare outputs
utt.assert_allclose(outputs[0], outputs[1]) # out utt.assert_allclose(outputs[0], outputs[1]) # out
......
...@@ -35,8 +35,8 @@ class TestDownsampleFactorMax(utt.InferShapeTester): ...@@ -35,8 +35,8 @@ class TestDownsampleFactorMax(utt.InferShapeTester):
if input.shape[-1] % ds[1]: if input.shape[-1] % ds[1]:
yi += 1 yi += 1
out_shp = list(input.shape[:-2]) out_shp = list(input.shape[:-2])
out_shp.append(input.shape[-2] / ds[0] + xi) out_shp.append(input.shape[-2] // ds[0] + xi)
out_shp.append(input.shape[-1] / ds[1] + yi) out_shp.append(input.shape[-1] // ds[1] + yi)
output_val = numpy.zeros(out_shp) output_val = numpy.zeros(out_shp)
func = numpy.max func = numpy.max
if mode == 'sum': if mode == 'sum':
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论