提交 4fe8381e authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Merge pull request #792 from nouiz/fix_py2.4

small Fix py2.4
......@@ -41,17 +41,23 @@ if (not hasattr(theano.sandbox, 'cuda') or
import pycuda.autoinit
pycuda_available = True
else:
import pycuda.driver
if hasattr(pycuda.driver.Context, "attach"):
pycuda.driver.Context.attach()
else:
# Now we always import this file when we call theano.sandbox.cuda.use
# So this should not happen normally.
# TODO: make this an error.
warnings.warn("For some unknow reason, theano.misc.pycuda_init was not"
" imported before Theano initialized the GPU and"
" your PyCUDA version is 2011.2.2 or earlier."
" To fix the problem, import theano.misc.pycuda_init"
" manually before using/initializing the GPU, use the"
" Theano flag pycuda.init=True or use a"
" more recent version of PyCUDA.")
try:
import pycuda.driver
pycuda_available = True
except ImportError:
pass
if pycuda_available:
if hasattr(pycuda.driver.Context, "attach"):
pycuda.driver.Context.attach()
else:
# Now we always import this file when we call
# theano.sandbox.cuda.use. So this should not happen
# normally.
# TODO: make this an error.
warnings.warn("For some unknow reason, theano.misc.pycuda_init was"
" not imported before Theano initialized the GPU and"
" your PyCUDA version is 2011.2.2 or earlier."
" To fix the problem, import theano.misc.pycuda_init"
" manually before using/initializing the GPU, use the"
" Theano flag pycuda.init=True or use a"
" more recent version of PyCUDA.")
......@@ -89,7 +89,7 @@ class Fourier(gof.Op):
if len(shape_a) == 1:
return [(n,)]
elif isinstance(axis, tensor.TensorConstant):
out_shape = list(shape_a[0: axis.data]) + [n] +\
out_shape = list(shape_a[0: axis.data.item()]) + [n] +\
list(shape_a[axis.data + 1:])
else:
l = len(shape_a)
......@@ -105,7 +105,7 @@ class Fourier(gof.Op):
a = inputs[0]
n = inputs[1]
axis = inputs[2]
output_storage[0][0] = numpy.fft.fft(a, n=int(n), axis=axis)
output_storage[0][0] = numpy.fft.fft(a, n=int(n), axis=axis.item())
def grad(self, inputs, cost_grad):
"""
......
......@@ -121,7 +121,7 @@ class Conv3D(theano.Op):
def perform(self, node, inputs, output_storage):
V, W, b, d = inputs
print "Conv3D python code"
# print "Conv3D python code"
output_storage[0][0] = computeH(V,W,b,d)
def infer_shape(self, node, input_shapes):
......
......@@ -44,7 +44,7 @@ class ConvGrad3D(theano.Op):
def perform(self, node, inputs, output_storage):
V, d, WShape, dCdH = inputs
print "ConvGradW3D python code"
# print "ConvGradW3D python code"
#partial C / partial W[j,z,k,l,m] = sum_i sum_p sum_q sum_r (partial C /partial H[i,j,p,q,r] ) * V[i,z,dr*p+k,dc*q+l,dt*r+m]
......
......@@ -83,7 +83,7 @@ class ConvTransp3D(theano.Op):
def perform(self, node, inputs, output_storage):
W, b, d, H, RShape = inputs
print "\t\t\t\tConvTransp3D python code"
# print "\t\t\t\tConvTransp3D python code"
output_storage[0][0] = computeR(W,b,d,H,RShape)
def c_code(self, node, nodename, inputs, outputs, sub):
......
......@@ -97,8 +97,8 @@ class DummyConvTransp3D:
self.dW = rng.uniform(-1, 1, self.W.get_value(borrow=True).shape)
self.db = rng.uniform(-1, 1, self.b.get_value(borrow=True).shape)
self.dH = rng.uniform(-1, 1, self.H.get_value(borrow=True).shape)
self.dW, self.db, self.dH = shared(self.dW), shared(self.db),
shared(self.dH)
self.dW, self.db = shared(self.dW), shared(self.db),
self.dH = shared(self.dH)
self.d = d
self.RShape = RShape
......
......@@ -276,7 +276,7 @@ class T_prepend(utt.InferShapeTester):
def test0(self):
x = tensor.matrix('x')
y = Prepend_scalar_constant_to_each_row(4.)(x)
f = theano.function([x], [y])
f = theano.function([x], y)
m = numpy.random.rand(3, 5)
my = f(m)
self.assertTrue(my.shape == (3, 6), my.shape)
......
......@@ -1245,6 +1245,8 @@ if imported_scipy_special:
else:
expected_erf = []
expected_erfc = []
expected_gammaln = []
expected_psi = []
skip_scipy = "scipy is not present"
ErfTester = makeBroadcastTester(
......
......@@ -8,6 +8,7 @@ import numpy
from numpy.testing import dec
import theano
from theano.gof.python25 import all
from theano.gof import Variable, Op
from theano import gof, scalar, config
......
......@@ -16,6 +16,7 @@ from theano import tensor
import theano.ifelse
from theano.ifelse import IfElse, ifelse
from theano.tests import unittest_tools as utt
from theano.gof.python25 import all
class test_ifelse(unittest.TestCase, utt.TestOptimizationMixin):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论