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

Fix W291: trailing whitespace

上级 8d102a94
......@@ -2,7 +2,7 @@ from theano.compile.ops import (
DeepCopyOp, deep_copy_op, register_deep_copy_op_c_code,
Shape, shape, register_shape_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,
SpecifyShape, specify_shape, register_specify_shape_c_code)
......
......@@ -933,7 +933,7 @@ class FunctionMaker(object):
found_graph_in_db = None
# The sole purpose of this loop is to set 'need_optimize' by
# going through graph_db, looking for graph that has the same
# computation performed.
# computation performed.
for graph_old, graph_optimized in graph_db.iteritems():
inputs_old = graph_old.inputs
outputs_old = graph_old.outputs
......@@ -1031,7 +1031,7 @@ class FunctionMaker(object):
print 'graph not found in graph_db, optimizing the graph'
self.fgraph.variables = set(gof.graph.variables(
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
# but once again the error couldbe worth
# investigating.
......@@ -1123,7 +1123,7 @@ class FunctionMaker(object):
# Check if some input variables are unused
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)
indices = [[input] + self.expand_in(input, _inputs) for input in inputs]
......@@ -1156,7 +1156,7 @@ class FunctionMaker(object):
if theano.config.cache_optimizations:
optimizer_profile = self.optimize_graph_with_cache(
optimizer, inputs, outputs)
else:
else:
optimizer_profile = optimizer(fgraph)
end_optimizer = time.time()
......
......@@ -5,7 +5,7 @@ import sys
from theano.compat import PY3
from theano.gof.compilelock import get_lock, release_lock
from theano import config
import cmodule
import cmodule
# 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.
......
......@@ -11,10 +11,10 @@ from theano.compat import cmp
# 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
# so, subject to the following conditions:
#
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
......
# Copyright (c) 2006-2008, R Oudkerk
# All rights reserved.
#
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
......@@ -13,7 +13,7 @@
# 3. Neither the name of author nor the names of any contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
......
......@@ -490,7 +490,7 @@ class GpuSoftmax (Op):
if config.gpuarray.sync:
cnda_thread_sync = "GpuArray_sync(&%(zz)s->ga);" % dict(zz=zz)
else:
cnda_thread_sync = ""
cnda_thread_sync = ""
return """
if (PyGpuArray_NDIM(%(x)s) != 2)
{
......@@ -686,7 +686,7 @@ class GpuSoftmaxWithBias (Op):
if config.gpuarray.sync:
cnda_thread_sync = "GpuArray_sync(&%(zz)s->ga);" % dict(zz=zz)
else:
cnda_thread_sync = ""
cnda_thread_sync = ""
return """
if (PyGpuArray_NDIM(%(x)s) != 2)
{
......
......@@ -1222,7 +1222,7 @@ class GetItem2d(gof.op.Op):
start = ind.start
stop = ind.stop
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
# of dimension 1 and int/uint dtype.
if scipy_ver < [0, 14] and ind.step != None:
......@@ -1239,7 +1239,7 @@ class GetItem2d(gof.op.Op):
raise ValueError((
"Impossible to index into a sparse matrix with "
"slice where step=%s" % step),
step.ndim, step.dtype)
step.ndim, step.dtype)
if start is None:
start = generic_None
......
......@@ -42,9 +42,9 @@ global_rng = N.random.RandomState(3423489)
dmatrix4 = T.TensorType('float64', (False, False, False, False))
def exec_multilayer_conv_nnet_old(conv_mode, ss, bsize, imshp, kshps, nkerns,
unroll_batch=0, unroll_kern=0, img=T.dmatrix(), validate=True,
conv_op_py=False, do_print=True, repeat=1,
def exec_multilayer_conv_nnet_old(conv_mode, ss, bsize, imshp, kshps, nkerns,
unroll_batch=0, unroll_kern=0, img=T.dmatrix(), validate=True,
conv_op_py=False, do_print=True, repeat=1,
unroll_patch=False, unroll_patch_size=False, verbose=0):
# build actual input images
......@@ -56,7 +56,7 @@ def exec_multilayer_conv_nnet_old(conv_mode, ss, bsize, imshp, kshps, nkerns,
kerns4 = dmatrix4()
# for each layer
ntot = 0
ntot = 0
tctot = 0
tpytot = 0
......@@ -76,7 +76,7 @@ def exec_multilayer_conv_nnet_old(conv_mode, ss, bsize, imshp, kshps, nkerns,
if conv_mode == 'full':
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[:, :, kshp[0]-1:-kshp[0]+1,
padimg[:, :, kshp[0]-1:-kshp[0]+1,
kshp[1]-1:-kshp[1]+1] = imgval
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,
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(),
do_print=True, repeat=1,
do_print=True, repeat=1,
unroll_patch=False, unroll_patch_size=False, verbose=0):
# build actual input images
......@@ -150,7 +150,7 @@ def exec_multilayer_conv_nnet(conv_mode, ss, bsize, imshp, kshps, nkerns,
kerns4 = dmatrix4()
# for each layer
ntot = 0
ntot = 0
tctot = 0
tpytot = 0
......@@ -195,7 +195,7 @@ def exec_multilayer_conv_nnet(conv_mode, ss, bsize, imshp, kshps, nkerns,
def speed_multilayer_conv():
# 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!
repeat = 3
......
......@@ -1929,16 +1929,16 @@ def local_useless_slice(node):
if isinstance(node.op, Subtensor):
slices = get_idx_list(node.inputs, node.op.idx_list)
last_slice = len(slices)
for s in slices[::-1]:
for s in slices[::-1]:
# check if slice and then check slice indices
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
else:
break
# check if we removed something
if last_slice < len(slices):
subtens = Subtensor(slices[:last_slice])
subtens = Subtensor(slices[:last_slice])
sl_ins = Subtensor.collapse(slices[:last_slice],
lambda x: isinstance(x, T.Variable))
out = subtens(node.inputs[0], *sl_ins)
......@@ -5619,8 +5619,8 @@ else:
# # Remove consider_constant #
# ############################
# Although the ops ConsiderConstant, ZeroGrad and DisconnectedGrad
# just returns the input, it should be removed from the graph to
# Although the ops ConsiderConstant, ZeroGrad and DisconnectedGrad
# just returns the input, it should be removed from the graph to
# make sure all possible optimizations can be applied.
register_canonicalize(gof.OpRemove(theano.gradient.consider_constant_),
'fast_compile', 'fast_run', name='remove_consider_constant')
......
......@@ -465,7 +465,7 @@ class TestDownsampleFactorMax(utt.InferShapeTester):
def test_max_pool_2d_2D_same_size(self):
rng = numpy.random.RandomState(utt.fetch_seed())
test_input_array = numpy.array([[[
[1., 2., 3., 4.],
[1., 2., 3., 4.],
[5., 6., 7., 8.]
]]])
test_answer_array = numpy.array([[[
......
......@@ -1586,7 +1586,7 @@ def test_local_useless_slice():
f_opt = theano.function([x], o, mode=mode_opt)
test_inp = numpy.random.randint(-10, 10, (4, 4)).astype('float32')
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
apply_node = f_opt.maker.fgraph.toposort()[0]
subtens = apply_node.op
......@@ -1599,7 +1599,7 @@ def test_local_useless_slice():
f_opt_check = theano.function([z], o2, 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]
subtens = apply_node.op
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,
assert rval == 0
noseids_file = '.noseids'
with open(noseids_file, 'rb') as f:
with open(noseids_file, 'rb') as f:
data = cPickle.load(f)
ids = data['ids']
......
......@@ -568,7 +568,7 @@ def test_subgraph_grad():
w2 = theano.shared(np.random.randn(4, 2))
a1 = theano.tensor.tanh(theano.tensor.dot(x, w1))
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())
cost1 = theano.tensor.sqr(w1.sum())
......@@ -591,7 +591,7 @@ def test_subgraph_grad():
param_grads = []
for i in xrange(2):
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]
)
next_grad = OrderedDict(zip(grad_ends[i], next_grad))
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论