提交 14c79a2a authored 作者: Frederic Bastien's avatar Frederic Bastien

Also skip bool and have a real gpuarray test.

上级 ece6d19d
......@@ -106,7 +106,7 @@ def contains_nan(arr, node=None, var=None):
"""
if not _is_numeric_value(arr, var):
return False
elif "int" in str(getattr(arr, 'dtype', '')):
elif getattr(arr, 'dtype', '') in T.discrete_dtypes:
return False
elif pygpu_available and isinstance(arr, GpuArray):
return np.isnan(f_gpua_min(arr.reshape(arr.size)))
......@@ -141,7 +141,7 @@ def contains_inf(arr, node=None, var=None):
"""
if not _is_numeric_value(arr, var):
return False
elif "int" in str(getattr(arr, 'dtype', '')):
elif getattr(arr, 'dtype', '') in T.discrete_dtypes:
return False
elif pygpu_available and isinstance(arr, GpuArray):
return (np.isinf(f_gpua_min(arr.reshape(arr.size))) or
......
......@@ -69,14 +69,3 @@ def test_NanGuardMode():
assert_raises(AssertionError, fun, biga) # big values
finally:
_logger.propagate = True
# Test with uint, we should not crash
x = T.matrix(dtype='uint8')
w = theano.shared(np.random.randn(5, 7).astype(theano.config.floatX))
y = T.dot(x, w)
a = (np.random.randn(3, 5).astype(theano.config.floatX) * 10).astype('uint8')
fun = theano.function(
[x], y,
mode=NanGuardMode(nan_is_error=True, inf_is_error=True)
)
fun(a) # normal values
# Test that normaly could be outside gpuarray, to have all gpuarray
# tests in the same directory, we put them here.
import theano
from theano import tensor
from theano.compile.nanguardmode import NanGuardMode
from .config import mode_with_gpu
def test_nan_guard_mode():
x = tensor.vector(dtype='int64')
y = x + 1
mode = NanGuardMode(nan_is_error=True, optimizer=mode_with_gpu.optimizer)
f = theano.function([x], y, mode=mode)
theano.printing.debugprint(f)
f([23, 7])
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论