提交 9bf77c89 authored 作者: Brandon T. Willard's avatar Brandon T. Willard

Replace theano.tensor alias T with tt in theano.compile.nanguardmode

上级 596b7746
import logging import logging
from six.moves import StringIO
import numpy as np import numpy as np
import theano import theano
import theano.tensor as tt
from six.moves import StringIO
from theano import config from theano import config
import theano.tensor as T
from theano.compile import Mode
from theano.compat import ValuesView from theano.compat import ValuesView
from .mode import get_mode from theano.compile.mode import get_mode, Mode
try: try:
from theano.gpuarray.type import GpuArrayType, _name_for_ctx from theano.gpuarray.type import GpuArrayType, _name_for_ctx
...@@ -106,7 +107,7 @@ def contains_nan(arr, node=None, var=None): ...@@ -106,7 +107,7 @@ def contains_nan(arr, node=None, var=None):
""" """
if not _is_numeric_value(arr, var): if not _is_numeric_value(arr, var):
return False return False
elif getattr(arr, "dtype", "") in T.discrete_dtypes: elif getattr(arr, "dtype", "") in tt.discrete_dtypes:
return False return False
elif pygpu_available and isinstance(arr, GpuArray): elif pygpu_available and isinstance(arr, GpuArray):
return np.isnan(f_gpua_min(arr.reshape(arr.size))) return np.isnan(f_gpua_min(arr.reshape(arr.size)))
...@@ -141,7 +142,7 @@ def contains_inf(arr, node=None, var=None): ...@@ -141,7 +142,7 @@ def contains_inf(arr, node=None, var=None):
""" """
if not _is_numeric_value(arr, var): if not _is_numeric_value(arr, var):
return False return False
elif getattr(arr, "dtype", "") in T.discrete_dtypes: elif getattr(arr, "dtype", "") in tt.discrete_dtypes:
return False return False
elif pygpu_available and isinstance(arr, GpuArray): elif pygpu_available and isinstance(arr, GpuArray):
return np.isinf(f_gpua_min(arr.reshape(arr.size))) or np.isinf( return np.isinf(f_gpua_min(arr.reshape(arr.size))) or np.isinf(
...@@ -168,9 +169,9 @@ def f_compute(op): ...@@ -168,9 +169,9 @@ def f_compute(op):
return result return result
f_gpua_min = f_compute(T.min) f_gpua_min = f_compute(tt.min)
f_gpua_max = f_compute(T.max) f_gpua_max = f_compute(tt.max)
f_gpua_absmax = f_compute(lambda x: T.max(T.abs_(x))) f_gpua_absmax = f_compute(lambda x: tt.max(tt.abs_(x)))
class NanGuardMode(Mode): class NanGuardMode(Mode):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论