提交 6df163f0 authored 作者: Brandon T. Willard's avatar Brandon T. Willard

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

上级 33667eb7
import pytest import pytest
import theano import theano
import theano.tensor as T import theano.tensor as tt
from theano.compile.mode import Mode, AddFeatureOptimizer from theano.compile.mode import Mode, AddFeatureOptimizer
from theano.gof.toolbox import NoOutputFromInplace from theano.gof.toolbox import NoOutputFromInplace
...@@ -11,10 +11,10 @@ from theano.gof.toolbox import NoOutputFromInplace ...@@ -11,10 +11,10 @@ from theano.gof.toolbox import NoOutputFromInplace
not theano.config.cxx, reason="G++ not available, so we need to skip this test." not theano.config.cxx, reason="G++ not available, so we need to skip this test."
) )
def test_no_output_from_implace(): def test_no_output_from_implace():
x = T.matrix() x = tt.matrix()
y = T.matrix() y = tt.matrix()
a = T.dot(x, y) a = tt.dot(x, y)
b = T.tanh(a) b = tt.tanh(a)
# Ensure that the elemwise op that produces the output is inplace when # Ensure that the elemwise op that produces the output is inplace when
# using a mode that does not include the optimization # using a mode that does not include the optimization
......
...@@ -5,7 +5,7 @@ Test compilation modes ...@@ -5,7 +5,7 @@ Test compilation modes
import copy import copy
import theano import theano
import theano.tensor as T import theano.tensor as tt
from theano.compile import Mode from theano.compile import Mode
...@@ -25,8 +25,8 @@ class TestBunchOfModes: ...@@ -25,8 +25,8 @@ class TestBunchOfModes:
modes = predef_modes + [Mode(linker, "fast_run") for linker in linkers] modes = predef_modes + [Mode(linker, "fast_run") for linker in linkers]
for mode in modes: for mode in modes:
x = T.matrix() x = tt.matrix()
y = T.vector() y = tt.vector()
f = theano.function([x, y], x + y, mode=mode) f = theano.function([x, y], x + y, mode=mode)
# test that it runs something # test that it runs something
f([[1, 2], [3, 4]], [5, 6]) f([[1, 2], [3, 4]], [5, 6])
......
...@@ -2,23 +2,23 @@ ...@@ -2,23 +2,23 @@
This test is for testing the NanGuardMode. This test is for testing the NanGuardMode.
""" """
import logging import logging
import pytest import pytest
import numpy as np import numpy as np
from theano.compile.nanguardmode import NanGuardMode
import theano import theano
import theano.tensor as T import theano.tensor as tt
from theano.compile.nanguardmode import NanGuardMode
def test_NanGuardMode(): def test_NanGuardMode():
# Tests if NanGuardMode is working by feeding in numpy.inf and numpy.nans # Tests if NanGuardMode is working by feeding in numpy.inf and numpy.nans
# intentionally. A working implementation should be able to capture all # intentionally. A working implementation should be able to capture all
# the abnormalties. # the abnormalties.
x = T.matrix() x = tt.matrix()
w = theano.shared(np.random.randn(5, 7).astype(theano.config.floatX)) w = theano.shared(np.random.randn(5, 7).astype(theano.config.floatX))
y = T.dot(x, w) y = tt.dot(x, w)
fun = theano.function( fun = theano.function(
[x], y, mode=NanGuardMode(nan_is_error=True, inf_is_error=True) [x], y, mode=NanGuardMode(nan_is_error=True, inf_is_error=True)
...@@ -51,8 +51,8 @@ def test_NanGuardMode(): ...@@ -51,8 +51,8 @@ def test_NanGuardMode():
nana = np.tile(np.asarray(np.nan).astype(theano.config.floatX), (3, 4, 5)) nana = np.tile(np.asarray(np.nan).astype(theano.config.floatX), (3, 4, 5))
biga = np.tile(np.asarray(1e20).astype(theano.config.floatX), (3, 4, 5)) biga = np.tile(np.asarray(1e20).astype(theano.config.floatX), (3, 4, 5))
x = T.tensor3() x = tt.tensor3()
y = x[:, T.arange(2), T.arange(2), None] y = x[:, tt.arange(2), tt.arange(2), None]
fun = theano.function( fun = theano.function(
[x], y, mode=NanGuardMode(nan_is_error=True, inf_is_error=True) [x], y, mode=NanGuardMode(nan_is_error=True, inf_is_error=True)
) )
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import numpy as np import numpy as np
import theano import theano
import theano.tensor as T import theano.tensor as tt
from six.moves import StringIO from six.moves import StringIO
from theano.ifelse import ifelse from theano.ifelse import ifelse
...@@ -23,10 +23,10 @@ class TestProfiling: ...@@ -23,10 +23,10 @@ class TestProfiling:
theano.config.profile_memory = True theano.config.profile_memory = True
theano.config.profiling.min_peak_memory = True theano.config.profiling.min_peak_memory = True
x = [T.fvector("val%i" % i) for i in range(3)] x = [tt.fvector("val%i" % i) for i in range(3)]
z = [] z = []
z += [T.outer(x[i], x[i + 1]).sum(axis=1) for i in range(len(x) - 1)] z += [tt.outer(x[i], x[i + 1]).sum(axis=1) for i in range(len(x) - 1)]
z += [x[i] + x[i + 1] for i in range(len(x) - 1)] z += [x[i] + x[i + 1] for i in range(len(x) - 1)]
p = theano.ProfileStats(False, gpu_checks=False) p = theano.ProfileStats(False, gpu_checks=False)
...@@ -79,10 +79,10 @@ class TestProfiling: ...@@ -79,10 +79,10 @@ class TestProfiling:
theano.config.profile = True theano.config.profile = True
theano.config.profile_memory = True theano.config.profile_memory = True
a, b = T.scalars("a", "b") a, b = tt.scalars("a", "b")
x, y = T.scalars("x", "y") x, y = tt.scalars("x", "y")
z = ifelse(T.lt(a, b), x * 2, y * 2) z = ifelse(tt.lt(a, b), x * 2, y * 2)
p = theano.ProfileStats(False, gpu_checks=False) p = theano.ProfileStats(False, gpu_checks=False)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论