Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f16c8763
提交
f16c8763
authored
2月 18, 2014
作者:
Razvan Pascanu
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1654 from lamblin/fix_mrg_grad_none
Use gradient_undefined instead of None in MRG uniform
上级
101b6810
c4faf858
全部展开
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
21 行增加
和
1 行删除
+21
-1
rng_mrg.py
theano/sandbox/rng_mrg.py
+5
-1
test_rng_mrg.py
theano/sandbox/test_rng_mrg.py
+16
-0
scan_op.py
theano/scan_module/scan_op.py
+0
-0
没有找到文件。
theano/sandbox/rng_mrg.py
浏览文件 @
f16c8763
...
@@ -10,6 +10,7 @@ import warnings
...
@@ -10,6 +10,7 @@ import warnings
import
numpy
import
numpy
from
theano
import
Op
,
Apply
,
shared
,
config
,
Variable
from
theano
import
Op
,
Apply
,
shared
,
config
,
Variable
from
theano
import
gradient
from
theano
import
tensor
from
theano
import
tensor
from
theano.tensor
import
(
raw_random
,
TensorType
,
as_tensor_variable
,
from
theano.tensor
import
(
raw_random
,
TensorType
,
as_tensor_variable
,
get_vector_length
,
cast
,
opt
,
scal
)
get_vector_length
,
cast
,
opt
,
scal
)
...
@@ -175,7 +176,10 @@ class mrg_uniform_base(Op):
...
@@ -175,7 +176,10 @@ class mrg_uniform_base(Op):
[
rstate
.
type
(),
self
.
output_type
()])
[
rstate
.
type
(),
self
.
output_type
()])
def
grad
(
self
,
inputs
,
ograd
):
def
grad
(
self
,
inputs
,
ograd
):
return
[
None
for
i
in
inputs
]
return
[
gradient
.
grad_undefined
(
self
,
k
,
inp
,
'No gradient defined through random sampling op'
)
for
k
,
inp
in
enumerate
(
inputs
)]
def
R_op
(
self
,
inputs
,
eval_points
):
def
R_op
(
self
,
inputs
,
eval_points
):
return
[
None
for
i
in
eval_points
]
return
[
None
for
i
in
eval_points
]
...
...
theano/sandbox/test_rng_mrg.py
浏览文件 @
f16c8763
...
@@ -755,3 +755,19 @@ def test_random_state_transfer():
...
@@ -755,3 +755,19 @@ def test_random_state_transfer():
su2
[
0
]
.
set_value
(
su1
[
0
]
.
get_value
())
su2
[
0
]
.
set_value
(
su1
[
0
]
.
get_value
())
numpy
.
testing
.
assert_array_almost_equal
(
f1
(),
f2
(),
decimal
=
6
)
numpy
.
testing
.
assert_array_almost_equal
(
f1
(),
f2
(),
decimal
=
6
)
def
test_gradient_scan
():
# Test for a crash when using MRG inside scan and taking the gradient
# See https://groups.google.com/d/msg/theano-dev/UbcYyU5m-M8/UO9UgXqnQP0J
theano_rng
=
MRG_RandomStreams
(
10
)
w
=
theano
.
shared
(
numpy
.
ones
(
1
,
dtype
=
'float32'
))
def
one_step
(
x
):
return
x
+
theano_rng
.
uniform
((
1
,),
dtype
=
'float32'
)
*
w
x
=
tensor
.
vector
(
dtype
=
'float32'
)
values
,
updates
=
theano
.
scan
(
one_step
,
outputs_info
=
x
,
n_steps
=
10
)
gw
=
theano
.
grad
(
tensor
.
sum
(
values
[
-
1
]),
w
)
f
=
theano
.
function
([
x
],
gw
)
f
(
numpy
.
arange
(
1
,
dtype
=
'float32'
))
theano/scan_module/scan_op.py
浏览文件 @
f16c8763
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论