提交 e869f5ef authored 作者: Benjamin Scellier's avatar Benjamin Scellier

file theano/gpuarray/tests/test_elemwise.py

上级 84cd72e6
from __future__ import absolute_import, print_function, division
import numpy
import numpy as np
import scipy.special
import theano
......@@ -45,8 +45,8 @@ def test_elemwise_pow():
output = base ** exp
f = theano.function([base, exp], output)
base_val = numpy.random.randint(0, 5, size=10).astype(dtype_base)
exp_val = numpy.random.randint(0, 3, size=10).astype(dtype_exp)
base_val = np.random.randint(0, 5, size=10).astype(dtype_base)
exp_val = np.random.randint(0, 3, size=10).astype(dtype_exp)
# Call the function to make sure the output is valid
out = f(base_val, exp_val)
......@@ -68,7 +68,7 @@ class TestMathErrorFunctions(TestCase):
# to have the GPU ops run on large data.
default_array = [x / 10.0 for x in range(-50, 50)] * 1000
for dtype in self.dtypes:
numpy_array = numpy.asarray(default_array, dtype=dtype)
numpy_array = np.asarray(default_array, dtype=dtype)
self.default_arrays[dtype] = numpy_array
self.expected_erfinv_outputs[dtype] = scipy.special.erfinv(numpy_array)
self.expected_erfcinv_outputs[dtype] = scipy.special.erfcinv(numpy_array)
......@@ -127,7 +127,7 @@ class test_float16():
o = (cz - cz**2 +
tensor.cast(x, 'int16') + tensor.cast(x, 'float32') +
tensor.cast(w, 'float16') -
tensor.constant(numpy.float16(1.0)))
tensor.constant(np.float16(1.0)))
theano.function([w, x, y], o, mode=mode_with_gpu)
......@@ -154,9 +154,9 @@ class test_float16():
i8.astype('float32')],
mode=mode_with_gpu)
d1 = (numpy.random.rand(4) * 10).astype('float16')
d2 = (numpy.random.rand(5) * 10).astype('float32')
d3 = (numpy.random.rand(6) * 10).astype('int8')
d1 = (np.random.rand(4) * 10).astype('float16')
d2 = (np.random.rand(5) * 10).astype('float32')
d3 = (np.random.rand(6) * 10).astype('int8')
res = f(d1, d2, d3)
for i, out in enumerate(f.outputs):
......@@ -337,9 +337,7 @@ class T_gpureduce_dtype(test_elemwise.T_reduce_dtype):
def speed_reduce10():
import numpy
import theano
data = numpy.random.rand(1000, 1000).astype("float32")
data = np.random.rand(1000, 1000).astype("float32")
m = theano.tensor.fmatrix()
f = theano.function([m], [m.sum(axis=0), m.T.sum(axis=0)],
mode=mode_with_gpu)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论