提交 b0e830ff authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Fix the test to actually work.

上级 558ad02e
import unittest
import numpy
import theano import theano
from theano.tensor import ftensor4
from theano.tensor.nnet.tests.test_conv import TestConv2D
# Skip tests if cuda_ndarray is not available. # Skip tests if cuda_ndarray is not available.
from nose.plugins.skip import SkipTest from nose.plugins.skip import SkipTest
...@@ -13,12 +14,30 @@ if theano.config.mode == 'FAST_COMPILE': ...@@ -13,12 +14,30 @@ if theano.config.mode == 'FAST_COMPILE':
else: else:
mode_with_gpu = theano.compile.mode.get_default_mode().including('gpu') mode_with_gpu = theano.compile.mode.get_default_mode().including('gpu')
class GTestConv2D(TestConv2D): def TestConv2dFFT(unittest.TestCase):
mode = mode_with_gpu
dtype = 'float32'
def setUp(self): def setUp(self):
super(GTestConv2D, self).setUp() self._prev = theano.confg.enable_conv2d_fft
self.input = ftensor4('input') theano.confg.enable_conv2d_fft = True
self.filters = ftensor4('filters')
def tearDown(self):
theano.confg.enable_conv2d_fft = self._prev
def test_valid(self):
inputs_shape = (5, 3, 7, 6)
filters_shape = (2, 3, 3, 3)
inputs_val = numpy.random.random(inputs_shape).astype('float32')
filters_val = numpy.random.random(filters_shape).astype('float32')
inputs = shared(inputs_val)
filters = shared(filters_val)
conv = theano.tensor.nnet.conv.conv2d(inputs, filters)
f_ref = theano.function([], conv)
f_fft = theano.function([], conv, mode=mode_with_gpu)
res_ref = f_ref()
res_fft = f_fft()
numpy.testing.assert_allclose(res_ref, res_fft)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论