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

file theano/gpuarray/tests/test_type.py

上级 80728319
from __future__ import absolute_import, print_function, division from __future__ import absolute_import, print_function, division
import os import os
import numpy import numpy as np
import theano import theano
from theano.compat import PY3 from theano.compat import PY3
...@@ -33,10 +33,10 @@ def test_values_eq_approx(): ...@@ -33,10 +33,10 @@ def test_values_eq_approx():
a = rand_gpuarray(20, dtype='float32') a = rand_gpuarray(20, dtype='float32')
assert GpuArrayType.values_eq_approx(a, a) assert GpuArrayType.values_eq_approx(a, a)
b = a.copy() b = a.copy()
b[0] = numpy.asarray(b[0]) + 1. b[0] = np.asarray(b[0]) + 1.
assert not GpuArrayType.values_eq_approx(a, b) assert not GpuArrayType.values_eq_approx(a, b)
b = a.copy() b = a.copy()
b[0] = -numpy.asarray(b[0]) b[0] = -np.asarray(b[0])
assert not GpuArrayType.values_eq_approx(a, b) assert not GpuArrayType.values_eq_approx(a, b)
...@@ -50,7 +50,7 @@ def test_specify_shape(): ...@@ -50,7 +50,7 @@ def test_specify_shape():
def test_filter_float(): def test_filter_float():
theano.compile.shared_constructor(gpuarray_shared_constructor) theano.compile.shared_constructor(gpuarray_shared_constructor)
try: try:
s = theano.shared(numpy.array(0.0, dtype='float32'), s = theano.shared(np.array(0.0, dtype='float32'),
target=test_ctx_name) target=test_ctx_name)
theano.function([], updates=[(s, 0.0)]) theano.function([], updates=[(s, 0.0)])
finally: finally:
...@@ -73,6 +73,6 @@ def test_unpickle_gpuarray_as_numpy_ndarray_flag0(): ...@@ -73,6 +73,6 @@ def test_unpickle_gpuarray_as_numpy_ndarray_flag0():
u = CompatUnpickler(fp) u = CompatUnpickler(fp)
mat = u.load() mat = u.load()
assert isinstance(mat, pygpu.gpuarray.GpuArray) assert isinstance(mat, pygpu.gpuarray.GpuArray)
assert numpy.asarray(mat)[0] == -42.0 assert np.asarray(mat)[0] == -42.0
finally: finally:
config.experimental.unpickle_gpu_on_cpu = oldflag config.experimental.unpickle_gpu_on_cpu = oldflag
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论