Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
5f0572d8
提交
5f0572d8
authored
6月 13, 2016
作者:
slefrancois
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
edit doc, make tests compatible with numpy<1.10
上级
6478aecf
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
17 行增加
和
21 行删除
+17
-21
fft.txt
doc/library/gpuarray/fft.txt
+5
-0
test_fft.py
theano/gpuarray/tests/test_fft.py
+6
-11
test_fft.py
theano/tensor/tests/test_fft.py
+6
-10
没有找到文件。
doc/library/gpuarray/fft.txt
浏览文件 @
5f0572d8
...
@@ -8,6 +8,11 @@ Performs Fast Fourier Transforms (FFT) on the GPU.
...
@@ -8,6 +8,11 @@ Performs Fast Fourier Transforms (FFT) on the GPU.
FFT gradients are implemented as the opposite Fourier transform of the output gradients.
FFT gradients are implemented as the opposite Fourier transform of the output gradients.
.. note ::
You must install `scikit-cuda <http://scikit-cuda.readthedocs.io/en/latest>`_
to compute Fourier transforms on the GPU.
.. warning ::
.. warning ::
The real and imaginary parts of the Fourier domain arrays are stored as a pair of float32
The real and imaginary parts of the Fourier domain arrays are stored as a pair of float32
arrays, emulating complex64. Since theano has limited support for complex
arrays, emulating complex64. Since theano has limited support for complex
...
...
theano/gpuarray/tests/test_fft.py
浏览文件 @
5f0572d8
...
@@ -123,10 +123,9 @@ class TestFFT(unittest.TestCase):
...
@@ -123,10 +123,9 @@ class TestFFT(unittest.TestCase):
res_rfft_comp
=
(
np
.
asarray
(
res_rfft
[:,
:,
:,
0
])
+
res_rfft_comp
=
(
np
.
asarray
(
res_rfft
[:,
:,
:,
0
])
+
1
j
*
np
.
asarray
(
res_rfft
[:,
:,
:,
1
]))
1
j
*
np
.
asarray
(
res_rfft
[:,
:,
:,
1
]))
rfft_ref
_ortho
=
numpy
.
fft
.
rfftn
(
inputs_val
,
axes
=
(
1
,
2
),
norm
=
'ortho'
)
rfft_ref
=
numpy
.
fft
.
rfftn
(
inputs_val
,
axes
=
(
1
,
2
)
)
utt
.
assert_allclose
(
rfft_ref_ortho
,
res_rfft_comp
,
utt
.
assert_allclose
(
rfft_ref
/
N
,
res_rfft_comp
,
atol
=
1e-4
,
rtol
=
1e-4
)
atol
=
1e-4
,
rtol
=
1e-4
)
# No normalization
# No normalization
rfft
=
theano
.
gpuarray
.
fft
.
curfft
(
inputs
,
norm
=
'no_norm'
)
rfft
=
theano
.
gpuarray
.
fft
.
curfft
(
inputs
,
norm
=
'no_norm'
)
...
@@ -135,8 +134,7 @@ class TestFFT(unittest.TestCase):
...
@@ -135,8 +134,7 @@ class TestFFT(unittest.TestCase):
res_rfft_comp
=
(
np
.
asarray
(
res_rfft
[:,
:,
:,
0
])
+
res_rfft_comp
=
(
np
.
asarray
(
res_rfft
[:,
:,
:,
0
])
+
1
j
*
np
.
asarray
(
res_rfft
[:,
:,
:,
1
]))
1
j
*
np
.
asarray
(
res_rfft
[:,
:,
:,
1
]))
utt
.
assert_allclose
(
rfft_ref_ortho
*
np
.
sqrt
(
N
*
N
),
utt
.
assert_allclose
(
rfft_ref
,
res_rfft_comp
,
atol
=
1e-4
,
rtol
=
1e-4
)
res_rfft_comp
,
atol
=
1e-4
,
rtol
=
1e-4
)
# Inverse FFT inputs
# Inverse FFT inputs
inputs_val
=
np
.
random
.
random
((
1
,
N
,
N
//
2
+
1
,
2
))
.
astype
(
'float32'
)
inputs_val
=
np
.
random
.
random
((
1
,
N
,
N
//
2
+
1
,
2
))
.
astype
(
'float32'
)
...
@@ -148,19 +146,16 @@ class TestFFT(unittest.TestCase):
...
@@ -148,19 +146,16 @@ class TestFFT(unittest.TestCase):
f_irfft
=
theano
.
function
([],
irfft
,
mode
=
mode_with_gpu
)
f_irfft
=
theano
.
function
([],
irfft
,
mode
=
mode_with_gpu
)
res_irfft
=
f_irfft
()
res_irfft
=
f_irfft
()
irfft_ref_ortho
=
numpy
.
fft
.
irfftn
(
irfft_ref
=
numpy
.
fft
.
irfftn
(
inputs_ref
,
axes
=
(
1
,
2
))
inputs_ref
,
axes
=
(
1
,
2
),
norm
=
'ortho'
)
utt
.
assert_allclose
(
irfft_ref_ortho
,
utt
.
assert_allclose
(
irfft_ref
*
N
,
res_irfft
,
atol
=
1e-4
,
rtol
=
1e-4
)
res_irfft
,
atol
=
1e-4
,
rtol
=
1e-4
)
# No normalization inverse FFT
# No normalization inverse FFT
irfft
=
theano
.
gpuarray
.
fft
.
cuirfft
(
inputs
,
norm
=
'no_norm'
)
irfft
=
theano
.
gpuarray
.
fft
.
cuirfft
(
inputs
,
norm
=
'no_norm'
)
f_irfft
=
theano
.
function
([],
irfft
,
mode
=
mode_with_gpu
)
f_irfft
=
theano
.
function
([],
irfft
,
mode
=
mode_with_gpu
)
res_irfft
=
f_irfft
()
res_irfft
=
f_irfft
()
utt
.
assert_allclose
(
irfft_ref_ortho
*
np
.
sqrt
(
N
*
N
),
utt
.
assert_allclose
(
irfft_ref
*
N
**
2
,
res_irfft
,
atol
=
1e-4
,
rtol
=
1e-4
)
res_irfft
,
atol
=
1e-4
,
rtol
=
1e-4
)
def
test_grad
(
self
):
def
test_grad
(
self
):
# The numerical gradient of the FFT is sensitive, must set large
# The numerical gradient of the FFT is sensitive, must set large
...
...
theano/tensor/tests/test_fft.py
浏览文件 @
5f0572d8
...
@@ -114,10 +114,9 @@ class TestFFT(unittest.TestCase):
...
@@ -114,10 +114,9 @@ class TestFFT(unittest.TestCase):
res_rfft_comp
=
(
numpy
.
asarray
(
res_rfft
[:,
:,
:,
0
])
+
res_rfft_comp
=
(
numpy
.
asarray
(
res_rfft
[:,
:,
:,
0
])
+
1
j
*
numpy
.
asarray
(
res_rfft
[:,
:,
:,
1
]))
1
j
*
numpy
.
asarray
(
res_rfft
[:,
:,
:,
1
]))
rfft_ref
_ortho
=
numpy
.
fft
.
rfftn
(
inputs_val
,
axes
=
(
1
,
2
),
norm
=
'ortho'
)
rfft_ref
=
numpy
.
fft
.
rfftn
(
inputs_val
,
axes
=
(
1
,
2
)
)
utt
.
assert_allclose
(
rfft_ref_ortho
,
res_rfft_comp
,
utt
.
assert_allclose
(
rfft_ref
/
N
,
res_rfft_comp
,
atol
=
1e-4
,
rtol
=
1e-4
)
atol
=
1e-4
,
rtol
=
1e-4
)
# No normalization
# No normalization
rfft
=
fft
.
rfft
(
inputs
,
norm
=
'no_norm'
)
rfft
=
fft
.
rfft
(
inputs
,
norm
=
'no_norm'
)
...
@@ -126,8 +125,7 @@ class TestFFT(unittest.TestCase):
...
@@ -126,8 +125,7 @@ class TestFFT(unittest.TestCase):
res_rfft_comp
=
(
numpy
.
asarray
(
res_rfft
[:,
:,
:,
0
])
+
res_rfft_comp
=
(
numpy
.
asarray
(
res_rfft
[:,
:,
:,
0
])
+
1
j
*
numpy
.
asarray
(
res_rfft
[:,
:,
:,
1
]))
1
j
*
numpy
.
asarray
(
res_rfft
[:,
:,
:,
1
]))
utt
.
assert_allclose
(
rfft_ref_ortho
*
numpy
.
sqrt
(
N
*
N
),
utt
.
assert_allclose
(
rfft_ref
,
res_rfft_comp
,
atol
=
1e-4
,
rtol
=
1e-4
)
res_rfft_comp
,
atol
=
1e-4
,
rtol
=
1e-4
)
# Inverse FFT inputs
# Inverse FFT inputs
inputs_val
=
numpy
.
random
.
random
((
1
,
N
,
N
//
2
+
1
,
2
))
inputs_val
=
numpy
.
random
.
random
((
1
,
N
,
N
//
2
+
1
,
2
))
...
@@ -139,18 +137,16 @@ class TestFFT(unittest.TestCase):
...
@@ -139,18 +137,16 @@ class TestFFT(unittest.TestCase):
f_irfft
=
theano
.
function
([],
irfft
)
f_irfft
=
theano
.
function
([],
irfft
)
res_irfft
=
f_irfft
()
res_irfft
=
f_irfft
()
irfft_ref
_ortho
=
numpy
.
fft
.
irfftn
(
inputs_ref
,
axes
=
(
1
,
2
),
norm
=
'ortho'
)
irfft_ref
=
numpy
.
fft
.
irfftn
(
inputs_ref
,
axes
=
(
1
,
2
)
)
utt
.
assert_allclose
(
irfft_ref_ortho
,
utt
.
assert_allclose
(
irfft_ref
*
N
,
res_irfft
,
atol
=
1e-4
,
rtol
=
1e-4
)
res_irfft
,
atol
=
1e-4
,
rtol
=
1e-4
)
# No normalization inverse FFT
# No normalization inverse FFT
irfft
=
fft
.
irfft
(
inputs
,
norm
=
'no_norm'
)
irfft
=
fft
.
irfft
(
inputs
,
norm
=
'no_norm'
)
f_irfft
=
theano
.
function
([],
irfft
)
f_irfft
=
theano
.
function
([],
irfft
)
res_irfft
=
f_irfft
()
res_irfft
=
f_irfft
()
utt
.
assert_allclose
(
irfft_ref_ortho
*
numpy
.
sqrt
(
N
*
N
),
utt
.
assert_allclose
(
irfft_ref
*
N
**
2
,
res_irfft
,
atol
=
1e-4
,
rtol
=
1e-4
)
res_irfft
,
atol
=
1e-4
,
rtol
=
1e-4
)
def
test_params
(
self
):
def
test_params
(
self
):
inputs_val
=
numpy
.
random
.
random
((
1
,
N
))
inputs_val
=
numpy
.
random
.
random
((
1
,
N
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论