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

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

上级 33667eb7
import pytest
import theano
import theano.tensor as T
import theano.tensor as tt
from theano.compile.mode import Mode, AddFeatureOptimizer
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."
)
def test_no_output_from_implace():
x = T.matrix()
y = T.matrix()
a = T.dot(x, y)
b = T.tanh(a)
x = tt.matrix()
y = tt.matrix()
a = tt.dot(x, y)
b = tt.tanh(a)
# Ensure that the elemwise op that produces the output is inplace when
# using a mode that does not include the optimization
......
......@@ -5,7 +5,7 @@ Test compilation modes
import copy
import theano
import theano.tensor as T
import theano.tensor as tt
from theano.compile import Mode
......@@ -25,8 +25,8 @@ class TestBunchOfModes:
modes = predef_modes + [Mode(linker, "fast_run") for linker in linkers]
for mode in modes:
x = T.matrix()
y = T.vector()
x = tt.matrix()
y = tt.vector()
f = theano.function([x, y], x + y, mode=mode)
# test that it runs something
f([[1, 2], [3, 4]], [5, 6])
......
......@@ -2,23 +2,23 @@
This test is for testing the NanGuardMode.
"""
import logging
import pytest
import numpy as np
from theano.compile.nanguardmode import NanGuardMode
import theano
import theano.tensor as T
import theano.tensor as tt
from theano.compile.nanguardmode import NanGuardMode
def test_NanGuardMode():
# Tests if NanGuardMode is working by feeding in numpy.inf and numpy.nans
# intentionally. A working implementation should be able to capture all
# the abnormalties.
x = T.matrix()
x = tt.matrix()
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(
[x], y, mode=NanGuardMode(nan_is_error=True, inf_is_error=True)
......@@ -51,8 +51,8 @@ def test_NanGuardMode():
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))
x = T.tensor3()
y = x[:, T.arange(2), T.arange(2), None]
x = tt.tensor3()
y = x[:, tt.arange(2), tt.arange(2), None]
fun = theano.function(
[x], y, mode=NanGuardMode(nan_is_error=True, inf_is_error=True)
)
......
......@@ -4,7 +4,7 @@
import numpy as np
import theano
import theano.tensor as T
import theano.tensor as tt
from six.moves import StringIO
from theano.ifelse import ifelse
......@@ -23,10 +23,10 @@ class TestProfiling:
theano.config.profile_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 += [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)]
p = theano.ProfileStats(False, gpu_checks=False)
......@@ -79,10 +79,10 @@ class TestProfiling:
theano.config.profile = True
theano.config.profile_memory = True
a, b = T.scalars("a", "b")
x, y = T.scalars("x", "y")
a, b = tt.scalars("a", "b")
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)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论