提交 4c90eecc authored 作者: Frederic's avatar Frederic

pep8

上级 7f3e28e4
...@@ -166,7 +166,8 @@ def test_consistency_cpu_parallel(): ...@@ -166,7 +166,8 @@ def test_consistency_cpu_parallel():
rstate = theano.shared(rstate) rstate = theano.shared(rstate)
new_rstate, sample = rng_mrg.mrg_uniform.new(rstate, ndim=None, new_rstate, sample = rng_mrg.mrg_uniform.new(rstate, ndim=None,
dtype=config.floatX, size=(n_substreams,)) dtype=config.floatX,
size=(n_substreams,))
# Not really necessary, just mimicking # Not really necessary, just mimicking
# rng_mrg.MRG_RandomStreams' behavior # rng_mrg.MRG_RandomStreams' behavior
sample.rstate = rstate sample.rstate = rstate
...@@ -219,7 +220,8 @@ def test_consistency_GPU_serial(): ...@@ -219,7 +220,8 @@ def test_consistency_GPU_serial():
rstate = float32_shared_constructor(tmp_float_buf) rstate = float32_shared_constructor(tmp_float_buf)
new_rstate, sample = rng_mrg.GPU_mrg_uniform.new(rstate, ndim=None, new_rstate, sample = rng_mrg.GPU_mrg_uniform.new(rstate, ndim=None,
dtype='float32', size=(1,)) dtype='float32',
size=(1,))
rstate.default_update = new_rstate rstate.default_update = new_rstate
# Not really necessary, just mimicking # Not really necessary, just mimicking
...@@ -278,7 +280,8 @@ def test_consistency_GPU_parallel(): ...@@ -278,7 +280,8 @@ def test_consistency_GPU_parallel():
rstate = float32_shared_constructor(tmp_float_buf) rstate = float32_shared_constructor(tmp_float_buf)
new_rstate, sample = rng_mrg.GPU_mrg_uniform.new(rstate, ndim=None, new_rstate, sample = rng_mrg.GPU_mrg_uniform.new(rstate, ndim=None,
dtype='float32', size=(n_substreams,)) dtype='float32',
size=(n_substreams,))
rstate.default_update = new_rstate rstate.default_update = new_rstate
# Not really necessary, just mimicking # Not really necessary, just mimicking
...@@ -381,7 +384,8 @@ def test_consistency_GPUA_parallel(): ...@@ -381,7 +384,8 @@ def test_consistency_GPUA_parallel():
rstate = gpuarray_shared_constructor(rstate) rstate = gpuarray_shared_constructor(rstate)
new_rstate, sample = rng_mrg.GPUA_mrg_uniform.new(rstate, ndim=None, new_rstate, sample = rng_mrg.GPUA_mrg_uniform.new(rstate, ndim=None,
dtype='float32', size=(n_substreams,)) dtype='float32',
size=(n_substreams,))
rstate.default_update = new_rstate rstate.default_update = new_rstate
# Not really necessary, just mimicking # Not really necessary, just mimicking
...@@ -452,7 +456,7 @@ def basictest(f, steps, sample_size, prefix="", allow_01=False, inputs=None, ...@@ -452,7 +456,7 @@ def basictest(f, steps, sample_size, prefix="", allow_01=False, inputs=None,
#print prefix, 'std', std #print prefix, 'std', std
if target_std is not None: if target_std is not None:
assert abs(std - target_std) < std_tol * (1 + abs(target_std)), ( assert abs(std - target_std) < std_tol * (1 + abs(target_std)), (
'bad std? %f %f %f' % (std, target_std, std_tol)) 'bad std? %f %f %f' % (std, target_std, std_tol))
#print prefix, 'time', dt #print prefix, 'time', dt
#print prefix, 'elements', steps * sample_size[0] * sample_size[1] #print prefix, 'elements', steps * sample_size[0] * sample_size[1]
#print prefix, 'samples/sec', steps * sample_size[0] * sample_size[1] / dt #print prefix, 'samples/sec', steps * sample_size[0] * sample_size[1] / dt
...@@ -522,8 +526,8 @@ def test_uniform(): ...@@ -522,8 +526,8 @@ def test_uniform():
# well, it's really that this test w GPU doesn't make sense otw # well, it's really that this test w GPU doesn't make sense otw
assert u.dtype == 'float32' assert u.dtype == 'float32'
f = theano.function(var_input, theano.Out( f = theano.function(var_input, theano.Out(
theano.sandbox.cuda.basic_ops.gpu_from_host(u), theano.sandbox.cuda.basic_ops.gpu_from_host(u),
borrow=True), mode=mode_with_gpu) borrow=True), mode=mode_with_gpu)
assert any([isinstance(node.op, assert any([isinstance(node.op,
theano.sandbox.rng_mrg.GPU_mrg_uniform) theano.sandbox.rng_mrg.GPU_mrg_uniform)
for node in f.maker.fgraph.toposort()]) for node in f.maker.fgraph.toposort()])
...@@ -613,8 +617,8 @@ def test_binomial(): ...@@ -613,8 +617,8 @@ def test_binomial():
#well, it's really that this test w GPU doesn't make sense otw #well, it's really that this test w GPU doesn't make sense otw
assert u.dtype == 'float32' assert u.dtype == 'float32'
f = theano.function(var_input, theano.Out( f = theano.function(var_input, theano.Out(
theano.sandbox.cuda.basic_ops.gpu_from_host(u), theano.sandbox.cuda.basic_ops.gpu_from_host(u),
borrow=True), mode=mode_with_gpu) borrow=True), mode=mode_with_gpu)
#theano.printing.debugprint(f) #theano.printing.debugprint(f)
gpu_out = numpy.asarray(f(*input)) gpu_out = numpy.asarray(f(*input))
#print 'random?[:10]\n', gpu_out[0, 0:10] #print 'random?[:10]\n', gpu_out[0, 0:10]
...@@ -799,9 +803,9 @@ def test_multinomial(): ...@@ -799,9 +803,9 @@ def test_multinomial():
#well, it's really that this test w GPU doesn't make sense otw #well, it's really that this test w GPU doesn't make sense otw
assert n.dtype == 'float32' assert n.dtype == 'float32'
f = theano.function( f = theano.function(
[], [],
theano.sandbox.cuda.basic_ops.gpu_from_host(n), theano.sandbox.cuda.basic_ops.gpu_from_host(n),
mode=mode_.including('gpu')) mode=mode_.including('gpu'))
#theano.printing.debugprint(f) #theano.printing.debugprint(f)
gpu_out = f() gpu_out = f()
...@@ -883,24 +887,26 @@ def test_multMatVect(): ...@@ -883,24 +887,26 @@ def test_multMatVect():
A2 = tensor.lmatrix('A2') A2 = tensor.lmatrix('A2')
s2 = tensor.ivector('s2') s2 = tensor.ivector('s2')
m2 = tensor.iscalar('m2') m2 = tensor.iscalar('m2')
g0 = rng_mrg.DotModulo()(A1, s1, m1, A2, s2, m2) g0 = rng_mrg.DotModulo()(A1, s1, m1, A2, s2, m2)
f0 = theano.function([A1, s1, m1, A2, s2, m2], g0) f0 = theano.function([A1, s1, m1, A2, s2, m2], g0)
A1 = numpy.random.randint(0, numpy.iinfo(numpy.int32).max, (3, 3)).astype('int64') i32max = numpy.iinfo(numpy.int32).max
s1 = numpy.random.randint(0, numpy.iinfo(numpy.int32).max, 3).astype('int32')
m1 = numpy.asarray(numpy.random.randint(numpy.iinfo(numpy.int32).max), dtype="int32") A1 = numpy.random.randint(0, i32max, (3, 3)).astype('int64')
A2 = numpy.random.randint(0, numpy.iinfo(numpy.int32).max, (3, 3)).astype('int64') s1 = numpy.random.randint(0, i32max, 3).astype('int32')
s2 = numpy.random.randint(0, numpy.iinfo(numpy.int32).max, 3).astype('int32') m1 = numpy.asarray(numpy.random.randint(i32max), dtype="int32")
m2 = numpy.asarray(numpy.random.randint(numpy.iinfo(numpy.int32).max), dtype="int32") A2 = numpy.random.randint(0, i32max, (3, 3)).astype('int64')
s2 = numpy.random.randint(0, i32max, 3).astype('int32')
m2 = numpy.asarray(numpy.random.randint(i32max), dtype="int32")
f0.input_storage[0].storage[0] = A1 f0.input_storage[0].storage[0] = A1
f0.input_storage[1].storage[0] = s1 f0.input_storage[1].storage[0] = s1
f0.input_storage[2].storage[0] = m1 f0.input_storage[2].storage[0] = m1
f0.input_storage[3].storage[0] = A2 f0.input_storage[3].storage[0] = A2
f0.input_storage[4].storage[0] = s2 f0.input_storage[4].storage[0] = s2
f0.input_storage[5].storage[0] = m2 f0.input_storage[5].storage[0] = m2
r_a1 = rng_mrg.matVecModM(A1, s1, m1) r_a1 = rng_mrg.matVecModM(A1, s1, m1)
r_a2 = rng_mrg.matVecModM(A2, s2, m2) r_a2 = rng_mrg.matVecModM(A2, s2, m2)
f0.fn() f0.fn()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论