提交 c502818a authored 作者: Ian Goodfellow's avatar Ian Goodfellow

moved more tests to deterministic interface

上级 eb7e7c9b
...@@ -869,5 +869,5 @@ def test_stack_rows_segfault_070312(): ...@@ -869,5 +869,5 @@ def test_stack_rows_segfault_070312():
out = theano.shared(numpy.random.rand(1, 2, 2, 3).astype('float32')) out = theano.shared(numpy.random.rand(1, 2, 2, 3).astype('float32'))
op = theano.tensor.nnet.conv.ConvOp(imshp=(80, 96, 96), kshp=(9, 9), op = theano.tensor.nnet.conv.ConvOp(imshp=(80, 96, 96), kshp=(9, 9),
nkern=1, bsize=1) nkern=1, bsize=1)
f = theano.function([], [], updates={out: op(img, kern)}) f = theano.function([], [], updates=[(out, op(img, kern))])
f() f()
...@@ -106,7 +106,7 @@ def test_alloc_memset_0(): ...@@ -106,7 +106,7 @@ def test_alloc_memset_0():
def test_gpuspecifyshape(): def test_gpuspecifyshape():
x = cuda.shared_constructor(numpy.ones(3,dtype='float32'), 'x') x = cuda.shared_constructor(numpy.ones(3,dtype='float32'), 'x')
m = theano.tensor.specify_shape(x + numpy.float32(1), (3,)) m = theano.tensor.specify_shape(x + numpy.float32(1), (3,))
f = theano.function([], updates={x:m * numpy.float32(2)}, f = theano.function([], updates=[(x, m * numpy.float32(2))],
mode=mode_with_gpu) mode=mode_with_gpu)
l = f.maker.fgraph.toposort() l = f.maker.fgraph.toposort()
assert not numpy.any([isinstance(x.op, cuda.HostFromGpu) for x in l]) assert not numpy.any([isinstance(x.op, cuda.HostFromGpu) for x in l])
......
...@@ -111,11 +111,11 @@ class T_updates(unittest.TestCase): ...@@ -111,11 +111,11 @@ class T_updates(unittest.TestCase):
up = tensor.unbroadcast(output_var.sum().dimshuffle('x', 'x'), 0, 1) up = tensor.unbroadcast(output_var.sum().dimshuffle('x', 'x'), 0, 1)
output_func = theano.function(inputs=[], outputs=[], output_func = theano.function(inputs=[], outputs=[],
updates={output_var: up}) updates=[(output_var, up)])
output_func() output_func()
up = tensor.patternbroadcast(output_var.sum().dimshuffle('x', 'x'), up = tensor.patternbroadcast(output_var.sum().dimshuffle('x', 'x'),
output_var.type.broadcastable) output_var.type.broadcastable)
output_func = theano.function(inputs=[], outputs=[], output_func = theano.function(inputs=[], outputs=[],
updates={output_var: up}) updates=[(output_var, up)])
output_func() output_func()
...@@ -46,17 +46,12 @@ from itertools import izip ...@@ -46,17 +46,12 @@ from itertools import izip
import logging import logging
import numpy import numpy
from theano.compile import SharedVariable, function
from theano import compile
from theano import gof from theano import gof
from theano.tensor import opt, TensorVariable from theano.tensor import opt, TensorVariable
from theano.tensor.sharedvar import TensorSharedVariable from theano.tensor.sharedvar import TensorSharedVariable
from theano import tensor from theano import tensor
from theano import config
from theano.updates import Updates
from theano.scalar.sharedvar import shared as scalar_shared from theano.scalar.sharedvar import shared as scalar_shared
from theano.compile.pfunc import rebuild_collect_shared from theano.compile.pfunc import rebuild_collect_shared
import theano
import scan_op import scan_op
import scan_utils import scan_utils
......
...@@ -9,7 +9,7 @@ import numpy ...@@ -9,7 +9,7 @@ import numpy
import theano import theano
import theano.tensor as T import theano.tensor as T
from theano.gof.python25 import any from theano.gof.python25 import any, OrderedDict
def gen_data(): def gen_data():
...@@ -293,7 +293,7 @@ def test_mlp(): ...@@ -293,7 +293,7 @@ def test_mlp():
# TODO: refine that and include only those # TODO: refine that and include only those
mode = theano.compile.get_default_mode().including('fast_run') mode = theano.compile.get_default_mode().including('fast_run')
updates2 = {} updates2 = OrderedDict()
updates2[classifier.hiddenLayer.params[0]]=T.grad(cost,classifier.hiddenLayer.params[0]) updates2[classifier.hiddenLayer.params[0]]=T.grad(cost,classifier.hiddenLayer.params[0])
train_model =theano.function( inputs = [index], train_model =theano.function( inputs = [index],
......
...@@ -526,8 +526,8 @@ def makeSharedTester(shared_constructor_, ...@@ -526,8 +526,8 @@ def makeSharedTester(shared_constructor_,
s = self.cast_value(s) s = self.cast_value(s)
s_shared = self.shared_constructor(s) s_shared = self.shared_constructor(s)
f = theano.function([], f = theano.function([],
updates={s_shared:theano.dot(a_shared,b_shared) updates=[(s_shared, theano.dot(a_shared,b_shared)
+s_shared}) +s_shared)])
topo=f.maker.fgraph.toposort() topo=f.maker.fgraph.toposort()
f() f()
#[Gemm{inplace}(<TensorType(float64, matrix)>, 0.01, <TensorType(float64, matrix)>, <TensorType(float64, matrix)>, 2e-06)] #[Gemm{inplace}(<TensorType(float64, matrix)>, 0.01, <TensorType(float64, matrix)>, <TensorType(float64, matrix)>, 2e-06)]
...@@ -541,8 +541,8 @@ def makeSharedTester(shared_constructor_, ...@@ -541,8 +541,8 @@ def makeSharedTester(shared_constructor_,
#now test with the specify shape op in the output #now test with the specify shape op in the output
f = theano.function([], s_shared.shape, f = theano.function([], s_shared.shape,
updates={s_shared:theano.dot(a_shared,b_shared) updates=[(s_shared, theano.dot(a_shared,b_shared)
+s_shared_specify}) +s_shared_specify)])
topo=f.maker.fgraph.toposort() topo=f.maker.fgraph.toposort()
shp=f() shp=f()
assert numpy.all(shp == (40,40)) assert numpy.all(shp == (40,40))
...@@ -557,8 +557,8 @@ def makeSharedTester(shared_constructor_, ...@@ -557,8 +557,8 @@ def makeSharedTester(shared_constructor_,
b_shared.get_value(borrow=True).shape) b_shared.get_value(borrow=True).shape)
f = theano.function([], s_shared.shape, f = theano.function([], s_shared.shape,
updates={s_shared:theano.dot(a_shared,b_shared) updates=[(s_shared, theano.dot(a_shared,b_shared)
+s_shared_specify}) +s_shared_specify)])
topo=f.maker.fgraph.toposort() topo=f.maker.fgraph.toposort()
shp=f() shp=f()
assert numpy.all(shp == (40,40)) assert numpy.all(shp == (40,40))
......
...@@ -8,8 +8,8 @@ import numpy.random ...@@ -8,8 +8,8 @@ import numpy.random
from theano.tests import unittest_tools as utt from theano.tests import unittest_tools as utt
''' '''
Different tests that are not connected to any particular Op, or functionality of Different tests that are not connected to any particular Op, or functionality of
Theano. Here will go for example code that we will publish in papers, that we Theano. Here will go for example code that we will publish in papers, that we
should ensure that it will remain operational should ensure that it will remain operational
''' '''
...@@ -55,7 +55,7 @@ class T_scipy(unittest.TestCase): ...@@ -55,7 +55,7 @@ class T_scipy(unittest.TestCase):
train = function( train = function(
inputs=[x,y], inputs=[x,y],
outputs=[prediction, xent], outputs=[prediction, xent],
updates={w:w-0.1*gw, b:b-0.1*gb}) updates=[(w, w-0.1*gw), (b, b-0.1*gb)])
predict = function(inputs=[x], outputs=prediction) predict = function(inputs=[x], outputs=prediction)
N = 4 N = 4
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论