提交 931464e2 authored 作者: amrithasuresh's avatar amrithasuresh

1. Updated numpy as np

2. Fixed indentation
上级 3bfb50f2
from __future__ import absolute_import, print_function, division from __future__ import absolute_import, print_function, division
import numpy import numpy as np
from numpy.testing import dec from numpy.testing import dec
import theano import theano
...@@ -10,7 +10,7 @@ from theano.tensor.fourier import Fourier, fft ...@@ -10,7 +10,7 @@ from theano.tensor.fourier import Fourier, fft
class TestFourier(utt.InferShapeTester): class TestFourier(utt.InferShapeTester):
rng = numpy.random.RandomState(43) rng = np.random.RandomState(43)
def setUp(self): def setUp(self):
super(TestFourier, self).setUp() super(TestFourier, self).setUp()
...@@ -20,24 +20,24 @@ class TestFourier(utt.InferShapeTester): ...@@ -20,24 +20,24 @@ class TestFourier(utt.InferShapeTester):
def test_perform(self): def test_perform(self):
a = tensor.dmatrix() a = tensor.dmatrix()
f = theano.function([a], self.op(a, n=10, axis=0)) f = theano.function([a], self.op(a, n=10, axis=0))
a = numpy.random.rand(8, 6) a = np.random.rand(8, 6)
assert numpy.allclose(f(a), numpy.fft.fft(a, 10, 0)) assert np.allclose(f(a), np.fft.fft(a, 10, 0))
def test_infer_shape(self): def test_infer_shape(self):
a = tensor.dvector() a = tensor.dvector()
self._compile_and_check([a], [self.op(a, 16, 0)], self._compile_and_check([a], [self.op(a, 16, 0)],
[numpy.random.rand(12)], [np.random.rand(12)],
self.op_class) self.op_class)
a = tensor.dmatrix() a = tensor.dmatrix()
for var in [self.op(a, 16, 1), self.op(a, None, 1), for var in [self.op(a, 16, 1), self.op(a, None, 1),
self.op(a, 16, None), self.op(a, None, None)]: self.op(a, 16, None), self.op(a, None, None)]:
self._compile_and_check([a], [var], self._compile_and_check([a], [var],
[numpy.random.rand(12, 4)], [np.random.rand(12, 4)],
self.op_class) self.op_class)
b = tensor.iscalar() b = tensor.iscalar()
for var in [self.op(a, 16, b), self.op(a, None, b)]: for var in [self.op(a, 16, b), self.op(a, None, b)]:
self._compile_and_check([a, b], [var], self._compile_and_check([a, b], [var],
[numpy.random.rand(12, 4), 0], [np.random.rand(12, 4), 0],
self.op_class) self.op_class)
@dec.skipif(True, "Complex grads not enabled, see #178") @dec.skipif(True, "Complex grads not enabled, see #178")
...@@ -54,10 +54,10 @@ class TestFourier(utt.InferShapeTester): ...@@ -54,10 +54,10 @@ class TestFourier(utt.InferShapeTester):
def fft_test4(a): def fft_test4(a):
return self.op(a, 4, 0) return self.op(a, 4, 0)
pts = [numpy.random.rand(5, 2, 4, 3), pts = [np.random.rand(5, 2, 4, 3),
numpy.random.rand(2, 3, 4), np.random.rand(2, 3, 4),
numpy.random.rand(2, 5), np.random.rand(2, 5),
numpy.random.rand(5)] np.random.rand(5)]
for fft_test in [fft_test1, fft_test2, fft_test3, fft_test4]: for fft_test in [fft_test1, fft_test2, fft_test3, fft_test4]:
for pt in pts: for pt in pts:
theano.gradient.verify_grad(fft_test, [pt], theano.gradient.verify_grad(fft_test, [pt],
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论