提交 e065342a authored 作者: Bart van Merrienboer's avatar Bart van Merrienboer

Fix W291: trailing whitespace

上级 8d102a94
...@@ -2,7 +2,7 @@ from theano.compile.ops import ( ...@@ -2,7 +2,7 @@ from theano.compile.ops import (
DeepCopyOp, deep_copy_op, register_deep_copy_op_c_code, DeepCopyOp, deep_copy_op, register_deep_copy_op_c_code,
Shape, shape, register_shape_c_code, Shape, shape, register_shape_c_code,
Shape_i, register_shape_i_c_code, Shape_i, register_shape_i_c_code,
ViewOp, view_op, register_view_op_c_code, FromFunctionOp, ViewOp, view_op, register_view_op_c_code, FromFunctionOp,
as_op, Rebroadcast, register_rebroadcast_c_code, as_op, Rebroadcast, register_rebroadcast_c_code,
SpecifyShape, specify_shape, register_specify_shape_c_code) SpecifyShape, specify_shape, register_specify_shape_c_code)
......
...@@ -933,7 +933,7 @@ class FunctionMaker(object): ...@@ -933,7 +933,7 @@ class FunctionMaker(object):
found_graph_in_db = None found_graph_in_db = None
# The sole purpose of this loop is to set 'need_optimize' by # The sole purpose of this loop is to set 'need_optimize' by
# going through graph_db, looking for graph that has the same # going through graph_db, looking for graph that has the same
# computation performed. # computation performed.
for graph_old, graph_optimized in graph_db.iteritems(): for graph_old, graph_optimized in graph_db.iteritems():
inputs_old = graph_old.inputs inputs_old = graph_old.inputs
outputs_old = graph_old.outputs outputs_old = graph_old.outputs
...@@ -1031,7 +1031,7 @@ class FunctionMaker(object): ...@@ -1031,7 +1031,7 @@ class FunctionMaker(object):
print 'graph not found in graph_db, optimizing the graph' print 'graph not found in graph_db, optimizing the graph'
self.fgraph.variables = set(gof.graph.variables( self.fgraph.variables = set(gof.graph.variables(
self.fgraph.inputs, self.fgraph.outputs)) self.fgraph.inputs, self.fgraph.outputs))
# check_integrity parameters was added to ignore # check_integrity parameters was added to ignore
#"excess cached variables" errors. Works that way #"excess cached variables" errors. Works that way
# but once again the error couldbe worth # but once again the error couldbe worth
# investigating. # investigating.
...@@ -1123,7 +1123,7 @@ class FunctionMaker(object): ...@@ -1123,7 +1123,7 @@ class FunctionMaker(object):
# Check if some input variables are unused # Check if some input variables are unused
self._check_unused_inputs(inputs, outputs, on_unused_input) self._check_unused_inputs(inputs, outputs, on_unused_input)
# Make a list of (SymbolicInput|SymblicInputKits, indices, [SymbolicInput,...]), one # Make a list of (SymbolicInput|SymblicInputKits, indices, [SymbolicInput,...]), one
# tuple for each input. (See Function.indices for more details) # tuple for each input. (See Function.indices for more details)
indices = [[input] + self.expand_in(input, _inputs) for input in inputs] indices = [[input] + self.expand_in(input, _inputs) for input in inputs]
...@@ -1156,7 +1156,7 @@ class FunctionMaker(object): ...@@ -1156,7 +1156,7 @@ class FunctionMaker(object):
if theano.config.cache_optimizations: if theano.config.cache_optimizations:
optimizer_profile = self.optimize_graph_with_cache( optimizer_profile = self.optimize_graph_with_cache(
optimizer, inputs, outputs) optimizer, inputs, outputs)
else: else:
optimizer_profile = optimizer(fgraph) optimizer_profile = optimizer(fgraph)
end_optimizer = time.time() end_optimizer = time.time()
......
...@@ -5,7 +5,7 @@ import sys ...@@ -5,7 +5,7 @@ import sys
from theano.compat import PY3 from theano.compat import PY3
from theano.gof.compilelock import get_lock, release_lock from theano.gof.compilelock import get_lock, release_lock
from theano import config from theano import config
import cmodule import cmodule
# TODO These two lines may be removed in the future, when we are 100% sure # TODO These two lines may be removed in the future, when we are 100% sure
# noone has an old cutils_ext.so lying around anymore. # noone has an old cutils_ext.so lying around anymore.
......
...@@ -11,10 +11,10 @@ from theano.compat import cmp ...@@ -11,10 +11,10 @@ from theano.compat import cmp
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is furnished to do # of the Software, and to permit persons to whom the Software is furnished to do
# so, subject to the following conditions: # so, subject to the following conditions:
# #
# The above copyright notice and this permission notice shall be included in all # The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software. # copies or substantial portions of the Software.
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
......
# Copyright (c) 2006-2008, R Oudkerk # Copyright (c) 2006-2008, R Oudkerk
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions
# are met: # are met:
# #
# 1. Redistributions of source code must retain the above copyright # 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer. # notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright # 2. Redistributions in binary form must reproduce the above copyright
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
# 3. Neither the name of author nor the names of any contributors may be # 3. Neither the name of author nor the names of any contributors may be
# used to endorse or promote products derived from this software # used to endorse or promote products derived from this software
# without specific prior written permission. # without specific prior written permission.
# #
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
......
...@@ -490,7 +490,7 @@ class GpuSoftmax (Op): ...@@ -490,7 +490,7 @@ class GpuSoftmax (Op):
if config.gpuarray.sync: if config.gpuarray.sync:
cnda_thread_sync = "GpuArray_sync(&%(zz)s->ga);" % dict(zz=zz) cnda_thread_sync = "GpuArray_sync(&%(zz)s->ga);" % dict(zz=zz)
else: else:
cnda_thread_sync = "" cnda_thread_sync = ""
return """ return """
if (PyGpuArray_NDIM(%(x)s) != 2) if (PyGpuArray_NDIM(%(x)s) != 2)
{ {
...@@ -686,7 +686,7 @@ class GpuSoftmaxWithBias (Op): ...@@ -686,7 +686,7 @@ class GpuSoftmaxWithBias (Op):
if config.gpuarray.sync: if config.gpuarray.sync:
cnda_thread_sync = "GpuArray_sync(&%(zz)s->ga);" % dict(zz=zz) cnda_thread_sync = "GpuArray_sync(&%(zz)s->ga);" % dict(zz=zz)
else: else:
cnda_thread_sync = "" cnda_thread_sync = ""
return """ return """
if (PyGpuArray_NDIM(%(x)s) != 2) if (PyGpuArray_NDIM(%(x)s) != 2)
{ {
......
...@@ -1222,7 +1222,7 @@ class GetItem2d(gof.op.Op): ...@@ -1222,7 +1222,7 @@ class GetItem2d(gof.op.Op):
start = ind.start start = ind.start
stop = ind.stop stop = ind.stop
step = ind.step step = ind.step
# If start or stop or step are None, make them a Generic # If start or stop or step are None, make them a Generic
# constant. Else, they should be converted to Tensor Variables # constant. Else, they should be converted to Tensor Variables
# of dimension 1 and int/uint dtype. # of dimension 1 and int/uint dtype.
if scipy_ver < [0, 14] and ind.step != None: if scipy_ver < [0, 14] and ind.step != None:
...@@ -1239,7 +1239,7 @@ class GetItem2d(gof.op.Op): ...@@ -1239,7 +1239,7 @@ class GetItem2d(gof.op.Op):
raise ValueError(( raise ValueError((
"Impossible to index into a sparse matrix with " "Impossible to index into a sparse matrix with "
"slice where step=%s" % step), "slice where step=%s" % step),
step.ndim, step.dtype) step.ndim, step.dtype)
if start is None: if start is None:
start = generic_None start = generic_None
......
...@@ -42,9 +42,9 @@ global_rng = N.random.RandomState(3423489) ...@@ -42,9 +42,9 @@ global_rng = N.random.RandomState(3423489)
dmatrix4 = T.TensorType('float64', (False, False, False, False)) dmatrix4 = T.TensorType('float64', (False, False, False, False))
def exec_multilayer_conv_nnet_old(conv_mode, ss, bsize, imshp, kshps, nkerns, def exec_multilayer_conv_nnet_old(conv_mode, ss, bsize, imshp, kshps, nkerns,
unroll_batch=0, unroll_kern=0, img=T.dmatrix(), validate=True, unroll_batch=0, unroll_kern=0, img=T.dmatrix(), validate=True,
conv_op_py=False, do_print=True, repeat=1, conv_op_py=False, do_print=True, repeat=1,
unroll_patch=False, unroll_patch_size=False, verbose=0): unroll_patch=False, unroll_patch_size=False, verbose=0):
# build actual input images # build actual input images
...@@ -56,7 +56,7 @@ def exec_multilayer_conv_nnet_old(conv_mode, ss, bsize, imshp, kshps, nkerns, ...@@ -56,7 +56,7 @@ def exec_multilayer_conv_nnet_old(conv_mode, ss, bsize, imshp, kshps, nkerns,
kerns4 = dmatrix4() kerns4 = dmatrix4()
# for each layer # for each layer
ntot = 0 ntot = 0
tctot = 0 tctot = 0
tpytot = 0 tpytot = 0
...@@ -76,7 +76,7 @@ def exec_multilayer_conv_nnet_old(conv_mode, ss, bsize, imshp, kshps, nkerns, ...@@ -76,7 +76,7 @@ def exec_multilayer_conv_nnet_old(conv_mode, ss, bsize, imshp, kshps, nkerns,
if conv_mode == 'full': if conv_mode == 'full':
padimg_shp = N.array(imshp[1:]) + 2*(N.array(kshp) - N.array([1, 1])) padimg_shp = N.array(imshp[1:]) + 2*(N.array(kshp) - N.array([1, 1]))
padimg = N.zeros(N.r_[bsize, imshp[0], padimg_shp]) padimg = N.zeros(N.r_[bsize, imshp[0], padimg_shp])
padimg[:, :, kshp[0]-1:-kshp[0]+1, padimg[:, :, kshp[0]-1:-kshp[0]+1,
kshp[1]-1:-kshp[1]+1] = imgval kshp[1]-1:-kshp[1]+1] = imgval
outshp = N.hstack((nkern, ConvOp.getOutputShape(imshp[1:], kshp, ss, conv_mode))) outshp = N.hstack((nkern, ConvOp.getOutputShape(imshp[1:], kshp, ss, conv_mode)))
...@@ -136,9 +136,9 @@ def exec_multilayer_conv_nnet_old(conv_mode, ss, bsize, imshp, kshps, nkerns, ...@@ -136,9 +136,9 @@ def exec_multilayer_conv_nnet_old(conv_mode, ss, bsize, imshp, kshps, nkerns,
return tctot, tpytot, ntot return tctot, tpytot, ntot
def exec_multilayer_conv_nnet(conv_mode, ss, bsize, imshp, kshps, nkerns, def exec_multilayer_conv_nnet(conv_mode, ss, bsize, imshp, kshps, nkerns,
unroll_batch=0, unroll_kern=0, img=T.dmatrix(), unroll_batch=0, unroll_kern=0, img=T.dmatrix(),
do_print=True, repeat=1, do_print=True, repeat=1,
unroll_patch=False, unroll_patch_size=False, verbose=0): unroll_patch=False, unroll_patch_size=False, verbose=0):
# build actual input images # build actual input images
...@@ -150,7 +150,7 @@ def exec_multilayer_conv_nnet(conv_mode, ss, bsize, imshp, kshps, nkerns, ...@@ -150,7 +150,7 @@ def exec_multilayer_conv_nnet(conv_mode, ss, bsize, imshp, kshps, nkerns,
kerns4 = dmatrix4() kerns4 = dmatrix4()
# for each layer # for each layer
ntot = 0 ntot = 0
tctot = 0 tctot = 0
tpytot = 0 tpytot = 0
...@@ -195,7 +195,7 @@ def exec_multilayer_conv_nnet(conv_mode, ss, bsize, imshp, kshps, nkerns, ...@@ -195,7 +195,7 @@ def exec_multilayer_conv_nnet(conv_mode, ss, bsize, imshp, kshps, nkerns,
def speed_multilayer_conv(): def speed_multilayer_conv():
# calculate the speed up of different combination of unroll # calculate the speed up of different combination of unroll
# put the paramter to the same you will try. # put the paramter to the same you will try.
validate = False # we don't validate the result to have it much faster! validate = False # we don't validate the result to have it much faster!
repeat = 3 repeat = 3
......
...@@ -1929,16 +1929,16 @@ def local_useless_slice(node): ...@@ -1929,16 +1929,16 @@ def local_useless_slice(node):
if isinstance(node.op, Subtensor): if isinstance(node.op, Subtensor):
slices = get_idx_list(node.inputs, node.op.idx_list) slices = get_idx_list(node.inputs, node.op.idx_list)
last_slice = len(slices) last_slice = len(slices)
for s in slices[::-1]: for s in slices[::-1]:
# check if slice and then check slice indices # check if slice and then check slice indices
if (isinstance(s, slice) and s.start is None and s.stop is None if (isinstance(s, slice) and s.start is None and s.stop is None
and (s.step is None or T.extract_constant(s.step) == 1)): and (s.step is None or T.extract_constant(s.step) == 1)):
last_slice -= 1 last_slice -= 1
else: else:
break break
# check if we removed something # check if we removed something
if last_slice < len(slices): if last_slice < len(slices):
subtens = Subtensor(slices[:last_slice]) subtens = Subtensor(slices[:last_slice])
sl_ins = Subtensor.collapse(slices[:last_slice], sl_ins = Subtensor.collapse(slices[:last_slice],
lambda x: isinstance(x, T.Variable)) lambda x: isinstance(x, T.Variable))
out = subtens(node.inputs[0], *sl_ins) out = subtens(node.inputs[0], *sl_ins)
...@@ -5619,8 +5619,8 @@ else: ...@@ -5619,8 +5619,8 @@ else:
# # Remove consider_constant # # # Remove consider_constant #
# ############################ # ############################
# Although the ops ConsiderConstant, ZeroGrad and DisconnectedGrad # Although the ops ConsiderConstant, ZeroGrad and DisconnectedGrad
# just returns the input, it should be removed from the graph to # just returns the input, it should be removed from the graph to
# make sure all possible optimizations can be applied. # make sure all possible optimizations can be applied.
register_canonicalize(gof.OpRemove(theano.gradient.consider_constant_), register_canonicalize(gof.OpRemove(theano.gradient.consider_constant_),
'fast_compile', 'fast_run', name='remove_consider_constant') 'fast_compile', 'fast_run', name='remove_consider_constant')
......
...@@ -465,7 +465,7 @@ class TestDownsampleFactorMax(utt.InferShapeTester): ...@@ -465,7 +465,7 @@ class TestDownsampleFactorMax(utt.InferShapeTester):
def test_max_pool_2d_2D_same_size(self): def test_max_pool_2d_2D_same_size(self):
rng = numpy.random.RandomState(utt.fetch_seed()) rng = numpy.random.RandomState(utt.fetch_seed())
test_input_array = numpy.array([[[ test_input_array = numpy.array([[[
[1., 2., 3., 4.], [1., 2., 3., 4.],
[5., 6., 7., 8.] [5., 6., 7., 8.]
]]]) ]]])
test_answer_array = numpy.array([[[ test_answer_array = numpy.array([[[
......
...@@ -1586,7 +1586,7 @@ def test_local_useless_slice(): ...@@ -1586,7 +1586,7 @@ def test_local_useless_slice():
f_opt = theano.function([x], o, mode=mode_opt) f_opt = theano.function([x], o, mode=mode_opt)
test_inp = numpy.random.randint(-10, 10, (4, 4)).astype('float32') test_inp = numpy.random.randint(-10, 10, (4, 4)).astype('float32')
assert all(f_opt(test_inp) == f_unopt(test_inp)),\ assert all(f_opt(test_inp) == f_unopt(test_inp)),\
"The optimization caused a mismatch in the result" "The optimization caused a mismatch in the result"
# test to see if the slice is truely gone # test to see if the slice is truely gone
apply_node = f_opt.maker.fgraph.toposort()[0] apply_node = f_opt.maker.fgraph.toposort()[0]
subtens = apply_node.op subtens = apply_node.op
...@@ -1599,7 +1599,7 @@ def test_local_useless_slice(): ...@@ -1599,7 +1599,7 @@ def test_local_useless_slice():
f_opt_check = theano.function([z], o2, mode=mode_opt) f_opt_check = theano.function([z], o2, mode=mode_opt)
f_opt_check_apply = theano.function([z], o3, mode=mode_opt) f_opt_check_apply = theano.function([z], o3, mode=mode_opt)
# The optimization shouldn't apply here # The optimization shouldn't apply here
apply_node = f_opt_check.maker.fgraph.toposort()[0] apply_node = f_opt_check.maker.fgraph.toposort()[0]
subtens = apply_node.op subtens = apply_node.op
assert [isinstance(idx, slice) for idx in subtens.idx_list].count(True) == 2 assert [isinstance(idx, slice) for idx in subtens.idx_list].count(True) == 2
......
...@@ -153,7 +153,7 @@ def run(stdout, stderr, argv, theano_nose, batch_size, time_profile, ...@@ -153,7 +153,7 @@ def run(stdout, stderr, argv, theano_nose, batch_size, time_profile,
assert rval == 0 assert rval == 0
noseids_file = '.noseids' noseids_file = '.noseids'
with open(noseids_file, 'rb') as f: with open(noseids_file, 'rb') as f:
data = cPickle.load(f) data = cPickle.load(f)
ids = data['ids'] ids = data['ids']
......
...@@ -568,7 +568,7 @@ def test_subgraph_grad(): ...@@ -568,7 +568,7 @@ def test_subgraph_grad():
w2 = theano.shared(np.random.randn(4, 2)) w2 = theano.shared(np.random.randn(4, 2))
a1 = theano.tensor.tanh(theano.tensor.dot(x, w1)) a1 = theano.tensor.tanh(theano.tensor.dot(x, w1))
a2 = theano.tensor.tanh(theano.tensor.dot(a1, w2)) a2 = theano.tensor.tanh(theano.tensor.dot(a1, w2))
cost2 = theano.tensor.sqr(a2 - t).sum() cost2 = theano.tensor.sqr(a2 - t).sum()
cost2 += theano.tensor.sqr(w2.sum()) cost2 += theano.tensor.sqr(w2.sum())
cost1 = theano.tensor.sqr(w1.sum()) cost1 = theano.tensor.sqr(w1.sum())
...@@ -591,7 +591,7 @@ def test_subgraph_grad(): ...@@ -591,7 +591,7 @@ def test_subgraph_grad():
param_grads = [] param_grads = []
for i in xrange(2): for i in xrange(2):
param_grad, next_grad = theano.subgraph_grad( param_grad, next_grad = theano.subgraph_grad(
wrt=params[i], end=grad_ends[i], wrt=params[i], end=grad_ends[i],
start=next_grad, cost=costs[i] start=next_grad, cost=costs[i]
) )
next_grad = OrderedDict(zip(grad_ends[i], next_grad)) next_grad = OrderedDict(zip(grad_ends[i], next_grad))
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论