Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
cbd1304d
提交
cbd1304d
authored
8月 13, 2012
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Disable grad/lop/rop/verify_grad on complex.
上级
b1013380
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
19 行增加
和
0 行删除
+19
-0
gradient.py
theano/gradient.py
+7
-0
test_complex.py
theano/tensor/tests/test_complex.py
+3
-0
test_elemwise.py
theano/tensor/tests/test_elemwise.py
+6
-0
test_fourier.py
theano/tensor/tests/test_fourier.py
+3
-0
没有找到文件。
theano/gradient.py
浏览文件 @
cbd1304d
...
@@ -132,6 +132,13 @@ def grad_sources_inputs(sources, graph_inputs, warn_type=True):
...
@@ -132,6 +132,13 @@ def grad_sources_inputs(sources, graph_inputs, warn_type=True):
#if all output gradients are None, continue
#if all output gradients are None, continue
if
all
(
map
(
lambda
x
:
x
is
None
,
g_outputs
)):
continue
if
all
(
map
(
lambda
x
:
x
is
None
,
g_outputs
)):
continue
#Disable all grad operation on complex. verify_grad don't
#support them and we don't know we want to handle them.
for
var
in
node
.
inputs
+
node
.
outputs
:
if
(
hasattr
(
var
.
type
,
'dtype'
)
and
"complex"
in
var
.
type
.
dtype
):
raise
Exception
(
"We do not support grad/Rop/Lop/verify_grad"
" on complex."
)
output_arg
=
g_outputs
output_arg
=
g_outputs
input_arg
=
node
.
inputs
input_arg
=
node
.
inputs
...
...
theano/tensor/tests/test_complex.py
浏览文件 @
cbd1304d
...
@@ -46,6 +46,7 @@ class TestRealImag(unittest.TestCase):
...
@@ -46,6 +46,7 @@ class TestRealImag(unittest.TestCase):
assert
numpy
.
all
(
rval
==
mval
[
0
]),
(
rval
,
mval
[
0
])
assert
numpy
.
all
(
rval
==
mval
[
0
]),
(
rval
,
mval
[
0
])
assert
numpy
.
all
(
ival
==
mval
[
1
]),
(
ival
,
mval
[
1
])
assert
numpy
.
all
(
ival
==
mval
[
1
]),
(
ival
,
mval
[
1
])
@dec.knownfailureif
(
True
,
"Complex grads not enabled, see #178"
)
def
test_complex_grads
(
self
):
def
test_complex_grads
(
self
):
def
f
(
m
):
def
f
(
m
):
c
=
complex
(
m
[
0
],
m
[
1
])
c
=
complex
(
m
[
0
],
m
[
1
])
...
@@ -103,6 +104,7 @@ class TestRealImag(unittest.TestCase):
...
@@ -103,6 +104,7 @@ class TestRealImag(unittest.TestCase):
print
e
.
analytic_grad
print
e
.
analytic_grad
raise
raise
@dec.knownfailureif
(
True
,
"Complex grads not enabled, see #178"
)
def
test_polar_grads
(
self
):
def
test_polar_grads
(
self
):
def
f
(
m
):
def
f
(
m
):
c
=
complex_from_polar
(
abs
(
m
[
0
]),
m
[
1
])
c
=
complex_from_polar
(
abs
(
m
[
0
]),
m
[
1
])
...
@@ -112,6 +114,7 @@ class TestRealImag(unittest.TestCase):
...
@@ -112,6 +114,7 @@ class TestRealImag(unittest.TestCase):
mval
=
numpy
.
asarray
(
rng
.
randn
(
2
,
5
))
mval
=
numpy
.
asarray
(
rng
.
randn
(
2
,
5
))
utt
.
verify_grad
(
f
,
[
mval
])
utt
.
verify_grad
(
f
,
[
mval
])
@dec.knownfailureif
(
True
,
"Complex grads not enabled, see #178"
)
def
test_abs_grad
(
self
):
def
test_abs_grad
(
self
):
def
f
(
m
):
def
f
(
m
):
c
=
complex
(
m
[
0
],
m
[
1
])
c
=
complex
(
m
[
0
],
m
[
1
])
...
...
theano/tensor/tests/test_elemwise.py
浏览文件 @
cbd1304d
...
@@ -628,6 +628,8 @@ class T_sum_dtype(unittest.TestCase):
...
@@ -628,6 +628,8 @@ class T_sum_dtype(unittest.TestCase):
sum_var
=
x
.
sum
(
dtype
=
output_dtype
,
axis
=
axis
)
sum_var
=
x
.
sum
(
dtype
=
output_dtype
,
axis
=
axis
)
assert
sum_var
.
dtype
==
output_dtype
assert
sum_var
.
dtype
==
output_dtype
if
"complex"
in
input_dtype
:
continue
# Check that we can take the gradient
# Check that we can take the gradient
grad_var
=
tensor
.
grad
(
sum_var
.
sum
(),
x
,
grad_var
=
tensor
.
grad
(
sum_var
.
sum
(),
x
,
disconnected_inputs
=
'ignore'
)
disconnected_inputs
=
'ignore'
)
...
@@ -676,6 +678,8 @@ class T_mean_dtype(unittest.TestCase):
...
@@ -676,6 +678,8 @@ class T_mean_dtype(unittest.TestCase):
assert
mean_var
.
dtype
==
sum_dtype
,
(
mean_var
.
dtype
,
sum_dtype
)
assert
mean_var
.
dtype
==
sum_dtype
,
(
mean_var
.
dtype
,
sum_dtype
)
# Check that we can take the gradient, when implemented
# Check that we can take the gradient, when implemented
if
"complex"
in
mean_var
.
dtype
:
continue
try
:
try
:
grad_var
=
tensor
.
grad
(
mean_var
.
sum
(),
x
,
grad_var
=
tensor
.
grad
(
mean_var
.
sum
(),
x
,
disconnected_inputs
=
'ignore'
)
disconnected_inputs
=
'ignore'
)
...
@@ -729,6 +733,8 @@ class T_prod_dtype(unittest.TestCase):
...
@@ -729,6 +733,8 @@ class T_prod_dtype(unittest.TestCase):
prod_var
=
x
.
prod
(
dtype
=
output_dtype
,
axis
=
axis
)
prod_var
=
x
.
prod
(
dtype
=
output_dtype
,
axis
=
axis
)
assert
prod_var
.
dtype
==
output_dtype
assert
prod_var
.
dtype
==
output_dtype
if
"complex"
in
output_dtype
:
continue
# Check that we can take the gradient
# Check that we can take the gradient
grad_var
=
tensor
.
grad
(
prod_var
.
sum
(),
x
,
grad_var
=
tensor
.
grad
(
prod_var
.
sum
(),
x
,
disconnected_inputs
=
'ignore'
)
disconnected_inputs
=
'ignore'
)
...
...
theano/tensor/tests/test_fourier.py
浏览文件 @
cbd1304d
import
numpy
import
numpy
from
numpy.testing
import
dec
import
theano
import
theano
from
theano
import
tensor
from
theano
import
tensor
from
theano.tests
import
unittest_tools
as
utt
from
theano.tests
import
unittest_tools
as
utt
...
@@ -37,6 +39,7 @@ class TestFourier(utt.InferShapeTester):
...
@@ -37,6 +39,7 @@ class TestFourier(utt.InferShapeTester):
[
numpy
.
random
.
rand
(
12
,
4
),
0
],
[
numpy
.
random
.
rand
(
12
,
4
),
0
],
self
.
op_class
)
self
.
op_class
)
@dec.knownfailureif
(
True
,
"Complex grads not enabled, see #178"
)
def
test_gradient
(
self
):
def
test_gradient
(
self
):
def
fft_test1
(
a
):
def
fft_test1
(
a
):
return
self
.
op
(
a
,
None
,
None
)
return
self
.
op
(
a
,
None
,
None
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论