Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
fae51675
提交
fae51675
authored
1月 10, 2017
作者:
Frédéric Bastien
提交者:
GitHub
1月 10, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5385 from gvtulder/f-ifelse-grad-gpu
Bug: gradient of ifelse with gpu inputs
上级
63006f46
a93cc0d9
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
14 行增加
和
1 行删除
+14
-1
ifelse.py
theano/ifelse.py
+3
-1
test_ifelse.py
theano/tests/test_ifelse.py
+11
-0
没有找到文件。
theano/ifelse.py
浏览文件 @
fae51675
...
@@ -173,7 +173,9 @@ class IfElse(Op):
...
@@ -173,7 +173,9 @@ class IfElse(Op):
# to keep them be cuda ndarrays
# to keep them be cuda ndarrays
nw_args
=
[]
nw_args
=
[]
for
x
in
args
:
for
x
in
args
:
if
isinstance
(
x
,
theano
.
Variable
):
if
hasattr
(
x
,
'_as_TensorVariable'
):
nw_args
.
append
(
x
.
_as_TensorVariable
())
elif
isinstance
(
x
,
theano
.
Variable
):
nw_args
.
append
(
x
)
nw_args
.
append
(
x
)
else
:
else
:
nw_args
.
append
(
theano
.
tensor
.
as_tensor_variable
(
x
))
nw_args
.
append
(
theano
.
tensor
.
as_tensor_variable
(
x
))
...
...
theano/tests/test_ifelse.py
浏览文件 @
fae51675
...
@@ -153,6 +153,17 @@ class test_ifelse(unittest.TestCase, utt.TestOptimizationMixin):
...
@@ -153,6 +153,17 @@ class test_ifelse(unittest.TestCase, utt.TestOptimizationMixin):
assert
numpy
.
all
(
numpy
.
asarray
(
gx0
)
==
0.
)
assert
numpy
.
all
(
numpy
.
asarray
(
gx0
)
==
0.
)
assert
numpy
.
all
(
numpy
.
asarray
(
gy0
)
==
1.
)
assert
numpy
.
all
(
numpy
.
asarray
(
gy0
)
==
1.
)
def
test_grad_cast_input
(
self
):
# Tests the gradient when both inputs are on the GPU.
x
=
tensor
.
vector
(
'x'
,
dtype
=
self
.
dtype
)
y
=
tensor
.
vector
(
'y'
,
dtype
=
self
.
dtype
)
c
=
tensor
.
iscalar
(
'c'
)
z
=
ifelse
(
c
,
self
.
cast_output
(
x
),
self
.
cast_output
(
y
))
gx
,
gy
=
tensor
.
grad
(
z
.
sum
(),
[
x
,
y
])
theano
.
function
([
c
,
x
,
y
],
[
gx
,
gy
],
mode
=
self
.
mode
)
def
test_multiple_out
(
self
):
def
test_multiple_out
(
self
):
x1
=
tensor
.
vector
(
'x1'
,
dtype
=
self
.
dtype
)
x1
=
tensor
.
vector
(
'x1'
,
dtype
=
self
.
dtype
)
x2
=
tensor
.
vector
(
'x2'
,
dtype
=
self
.
dtype
)
x2
=
tensor
.
vector
(
'x2'
,
dtype
=
self
.
dtype
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论