提交 13479941 authored 作者: Frederic Bastien's avatar Frederic Bastien

remplace T. by tensor.

上级 b879aa80
...@@ -12,9 +12,8 @@ from scipy.signal import convolve2d ...@@ -12,9 +12,8 @@ from scipy.signal import convolve2d
import scipy.sparse as sparse import scipy.sparse as sparse
import numpy import numpy
from theano import function from theano import function, tensor
import theano import theano
import theano.tensor as T
from theano.sparse.sandbox import sp from theano.sparse.sandbox import sp
from theano.tests import unittest_tools as utt from theano.tests import unittest_tools as utt
...@@ -34,9 +33,9 @@ class TestSP(unittest.TestCase): ...@@ -34,9 +33,9 @@ class TestSP(unittest.TestCase):
convmodes = ('full','valid') convmodes = ('full','valid')
# symbolic stuff # symbolic stuff
bias = T.dvector() bias = tensor.dvector()
kerns = T.dmatrix() kerns = tensor.dmatrix()
input = T.dmatrix() input = tensor.dmatrix()
rng = numpy.random.RandomState(3423489) rng = numpy.random.RandomState(3423489)
filters = rng.randn(nkern,numpy.prod(kshp)) filters = rng.randn(nkern,numpy.prod(kshp))
biasvals = rng.randn(nkern) biasvals = rng.randn(nkern)
...@@ -90,7 +89,7 @@ class TestSP(unittest.TestCase): ...@@ -90,7 +89,7 @@ class TestSP(unittest.TestCase):
assert (temp < 1e-5).all() assert (temp < 1e-5).all()
# test downward propagation -- symbolic stuff # test downward propagation -- symbolic stuff
#vis = T.grad(output, input, output) #vis = tensor.grad(output, input, output)
#downprop = function([kerns,input], vis, mode=mode) #downprop = function([kerns,input], vis, mode=mode)
#visval = downprop(filters,img1d) #visval = downprop(filters,img1d)
## test downward propagation -- reference implementation ## test downward propagation -- reference implementation
...@@ -139,9 +138,9 @@ class TestSP(unittest.TestCase): ...@@ -139,9 +138,9 @@ class TestSP(unittest.TestCase):
convmodes = ('full','valid',) convmodes = ('full','valid',)
# symbolic stuff # symbolic stuff
bias = T.dvector() bias = tensor.dvector()
kerns = T.dvector() kerns = tensor.dvector()
input = T.dmatrix() input = tensor.dmatrix()
rng = numpy.random.RandomState(3423489) rng = numpy.random.RandomState(3423489)
import theano.gof as gof import theano.gof as gof
...@@ -197,7 +196,7 @@ class TestSP(unittest.TestCase): ...@@ -197,7 +196,7 @@ class TestSP(unittest.TestCase):
assert (temp < 1e-10).all() assert (temp < 1e-10).all()
# test downward propagation # test downward propagation
vis = T.grad(0.5*T.sqr(output).sum(), input) vis = tensor.grad(0.5*tensor.sqr(output).sum(), input)
downprop = function([kerns,output], vis) downprop = function([kerns,output], vis)
temp1 = time.time() temp1 = time.time()
for zz in range(100): for zz in range(100):
...@@ -224,8 +223,8 @@ class TestSP(unittest.TestCase): ...@@ -224,8 +223,8 @@ class TestSP(unittest.TestCase):
convmodes = ('full','valid',) convmodes = ('full','valid',)
# symbolic stuff # symbolic stuff
kerns = [T.dvector(),T.dvector()] kerns = [tensor.dvector(),tensor.dvector()]
input = T.dmatrix() input = tensor.dmatrix()
rng = numpy.random.RandomState(3423489) rng = numpy.random.RandomState(3423489)
# build actual input images # build actual input images
...@@ -262,8 +261,8 @@ class TestSP(unittest.TestCase): ...@@ -262,8 +261,8 @@ class TestSP(unittest.TestCase):
convmodes = ('full',)#'valid',) convmodes = ('full',)#'valid',)
# symbolic stuff # symbolic stuff
kerns = [T.dmatrix(),T.dmatrix()] kerns = [tensor.dmatrix(),tensor.dmatrix()]
input = T.dmatrix() input = tensor.dmatrix()
rng = numpy.random.RandomState(3423489) rng = numpy.random.RandomState(3423489)
# build actual input images # build actual input images
...@@ -301,7 +300,7 @@ class TestSP(unittest.TestCase): ...@@ -301,7 +300,7 @@ class TestSP(unittest.TestCase):
maxpoolshps = ((2,2),(3,3),(4,4),(5,5),(6,6)) maxpoolshps = ((2,2),(3,3),(4,4),(5,5),(6,6))
imval = numpy.random.rand(4,5,10,10) imval = numpy.random.rand(4,5,10,10)
images = T.dmatrix() images = tensor.dmatrix()
for maxpoolshp in maxpoolshps: for maxpoolshp in maxpoolshps:
# symbolic stuff # symbolic stuff
...@@ -340,10 +339,10 @@ class TestSP(unittest.TestCase): ...@@ -340,10 +339,10 @@ class TestSP(unittest.TestCase):
#convmodes = ('full','valid',) #convmodes = ('full','valid',)
convmodes = ('full',) convmodes = ('full',)
kerns = T.dvector() kerns = tensor.dvector()
indices = T.ivector() indices = tensor.ivector()
indptr = T.ivector() indptr = tensor.ivector()
spmat_shape = T.ivector() spmat_shape = tensor.ivector()
for mode in ['FAST_COMPILE','FAST_RUN']: for mode in ['FAST_COMPILE','FAST_RUN']:
for conv_mode in convmodes: for conv_mode in convmodes:
...@@ -402,7 +401,7 @@ class TestSP(unittest.TestCase): ...@@ -402,7 +401,7 @@ class TestSP(unittest.TestCase):
def test_diagonal(): def test_diagonal():
for K in 1, 5: for K in 1, 5:
d = T.ivector() d = tensor.ivector()
sd = sp.square_diagonal(d) sd = sp.square_diagonal(d)
...@@ -446,7 +445,7 @@ def test_row_scale(): ...@@ -446,7 +445,7 @@ def test_row_scale():
assert numpy.all(f(x_val, s_val).toarray() == (x_val_dense.T * s_val).T) assert numpy.all(f(x_val, s_val).toarray() == (x_val_dense.T * s_val).T)
if 0: if 0:
T.verify_grad(None, d, [x_val, s_val], tensor.verify_grad(None, d, [x_val, s_val],
mode=theano.Mode(linker='py', optimizer='fast_compile')) mode=theano.Mode(linker='py', optimizer='fast_compile'))
else: else:
print >> sys.stderr, "WARNING: skipping gradient test because verify_grad doesn't support sparse arguments" print >> sys.stderr, "WARNING: skipping gradient test because verify_grad doesn't support sparse arguments"
...@@ -477,7 +476,7 @@ def test_col_scale(): ...@@ -477,7 +476,7 @@ def test_col_scale():
assert numpy.all(f(x_val, s_val).toarray() == (x_val_dense * s_val)) assert numpy.all(f(x_val, s_val).toarray() == (x_val_dense * s_val))
if 0: if 0:
T.verify_grad(None, d, [x_val, s_val], tensor.verify_grad(None, d, [x_val, s_val],
mode=theano.Mode(linker='py', optimizer='fast_compile')) mode=theano.Mode(linker='py', optimizer='fast_compile'))
else: else:
print >> sys.stderr, "WARNING: skipping gradient test because verify_grad doesn't support sparse arguments" print >> sys.stderr, "WARNING: skipping gradient test because verify_grad doesn't support sparse arguments"
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论