def test_other(self, dtype, input, sigma): theano.config.compute_test_value = 'ignore' sigma_theano = theano.shared(sigma) window_radius = int(sigma * 4) if input == 'pixel': test_data = np.ones((100, 100)) test_data[50, 50] = 2 elif input == 'random': test_data = 10 * np.ones((100, 100)) test_data += np.random.randn(100, 100) else: raise ValueError(input) test_data = test_data.astype(dtype) data = T.tensor3('data', dtype=dtype) data.tag.test_value = test_data[np.newaxis, :, :] print(data.dtype) blur = gaussian_filter(data, sigma_theano, window_radius) f = theano.function([data], blur) out = f(test_data[np.newaxis, :, :])[0, :, :] scipy_out = scipy_filter(test_data, sigma, mode='nearest') if dtype == 'float32': rtol = 5e-6 else: rtol = 1e-7 np.testing.assert_allclose(out, scipy_out, rtol=rtol)
def check_other(self, dtype, input, sigma): theano.config.compute_test_value = 'ignore' sigma_theano = theano.shared(sigma) window_radius = int(sigma*4) if input == 'pixel': test_data = np.ones((100, 100)) test_data[50, 50] = 2 elif input == 'random': test_data = 10*np.ones((100, 100)) test_data += np.random.randn(100, 100) else: raise ValueError(input) test_data = test_data.astype(dtype) data = T.tensor3('data', dtype=dtype) data.tag.test_value = test_data[np.newaxis, :, :] print(data.dtype) blur = gaussian_filter(data, sigma_theano, window_radius) f = theano.function([data], blur) out = f(test_data[np.newaxis, :, :])[0, :, :] scipy_out = scipy_filter(test_data, sigma, mode='nearest') if dtype == 'float32': rtol = 1e-6 else: rtol = 1e-7 np.testing.assert_allclose(out, scipy_out, rtol=rtol)
def test_blur(self): theano.config.floatX = 'float64' data = T.matrix('data') data.tag.test_value = np.random.randn(10, 10) blur = Blur(data, sigma=20.0, window_radius=80) tmp = np.random.randn(1000, 2000) tmp += 10.0 out = blur.output.eval({data: tmp}) scipy_out = scipy_filter(tmp, 20.0, mode='nearest') np.testing.assert_allclose(out, scipy_out)
def test_blur(self): theano.config.floatX = 'float64' data = T.matrix('data') data.tag.test_value = np.random.randn(10, 10) blur = Blur(data, sigma=20.0, window_radius = 80) tmp = np.random.randn(1000, 2000) tmp += 10.0 out = blur.output.eval({data: tmp}) scipy_out = scipy_filter(tmp, 20.0, mode='nearest') np.testing.assert_allclose(out, scipy_out)