Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f2f347a5
提交
f2f347a5
authored
2月 20, 2017
作者:
Sina Honari
提交者:
Pascal Lamblin
4月 18, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixing bugs + adding some tests
上级
13f31289
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
53 行增加
和
2 行删除
+53
-2
gradient.py
theano/gradient.py
+2
-2
rng_mrg.py
theano/sandbox/rng_mrg.py
+1
-0
test_rng_mrg.py
theano/sandbox/tests/test_rng_mrg.py
+50
-0
没有找到文件。
theano/gradient.py
浏览文件 @
f2f347a5
...
@@ -1996,13 +1996,13 @@ def zero_grad(x):
...
@@ -1996,13 +1996,13 @@ def zero_grad(x):
class
UndefinedGrad
(
ViewOp
):
class
UndefinedGrad
(
ViewOp
):
def
grad
(
self
,
args
,
g_outs
):
def
grad
(
self
,
args
,
g_outs
):
return
[
grad_undefined
(
self
,
i
,
inp
[
i
])
for
i
in
xrang
e
(
args
)]
return
[
grad_undefined
(
self
,
i
,
arg
)
for
i
,
arg
in
enumerat
e
(
args
)]
def
R_op
(
self
,
inputs
,
eval_points
):
def
R_op
(
self
,
inputs
,
eval_points
):
return
[
None
]
return
[
None
]
def
connection_pattern
(
self
,
node
):
def
connection_pattern
(
self
,
node
):
return
[[
Fals
e
]]
return
[[
Tru
e
]]
undefined_grad_
=
UndefinedGrad
()
undefined_grad_
=
UndefinedGrad
()
...
...
theano/sandbox/rng_mrg.py
浏览文件 @
f2f347a5
...
@@ -937,6 +937,7 @@ class MRG_RandomStreams(object):
...
@@ -937,6 +937,7 @@ class MRG_RandomStreams(object):
raise
TypeError
(
"For now, p has to be specified in "
raise
TypeError
(
"For now, p has to be specified in "
"MRG_RandomStreams.choice."
)
"MRG_RandomStreams.choice."
)
p
=
as_tensor_variable
(
p
)
p
=
as_tensor_variable
(
p
)
p
=
undefined_grad
(
p
)
if
ndim
is
not
None
:
if
ndim
is
not
None
:
raise
ValueError
(
"ndim argument to "
raise
ValueError
(
"ndim argument to "
...
...
theano/sandbox/tests/test_rng_mrg.py
浏览文件 @
f2f347a5
...
@@ -687,6 +687,56 @@ def test_overflow_cpu():
...
@@ -687,6 +687,56 @@ def test_overflow_cpu():
rng_mrg_overflow
(
sizes
,
fct
,
config
.
mode
,
should_raise_error
=
False
)
rng_mrg_overflow
(
sizes
,
fct
,
config
.
mode
,
should_raise_error
=
False
)
def
test_udefined_grad
():
srng
=
MRG_RandomStreams
(
seed
=
1234
)
# checking uniform distribution
low
=
T
.
scalar
()
out
=
srng
.
uniform
((),
low
=
low
)
assert_raises
(
theano
.
gradient
.
NullTypeGradError
,
theano
.
grad
,
out
,
low
)
high
=
T
.
scalar
()
out
=
srng
.
uniform
((),
low
=
0
,
high
=
high
)
assert_raises
(
theano
.
gradient
.
NullTypeGradError
,
theano
.
grad
,
out
,
high
)
out
=
srng
.
uniform
((),
low
=
low
,
high
=
high
)
assert_raises
(
theano
.
gradient
.
NullTypeGradError
,
theano
.
grad
,
out
,
(
low
,
high
))
# checking binomial distribution
prob
=
T
.
scalar
()
out
=
srng
.
binomial
((),
p
=
prob
)
assert_raises
(
theano
.
gradient
.
NullTypeGradError
,
theano
.
grad
,
out
,
prob
)
# checking multinomial distribution
prob1
=
T
.
scalar
()
prob2
=
T
.
scalar
()
out
=
srng
.
multinomial
((),
pvals
=
[
prob1
,
0.5
,
0.25
],
n
=
4
)
assert_raises
(
theano
.
gradient
.
NullTypeGradError
,
theano
.
grad
,
out
,
prob1
)
out
=
srng
.
multinomial
((),
pvals
=
[
prob1
,
prob2
])
assert_raises
(
theano
.
gradient
.
NullTypeGradError
,
theano
.
grad
,
out
,
(
prob1
,
prob2
))
# checking choice
out
=
srng
.
choice
((),
p
=
[[
prob1
,
prob2
]],
replace
=
False
)
assert_raises
(
theano
.
gradient
.
NullTypeGradError
,
theano
.
grad
,
out
,
(
prob1
,
prob2
))
# checking normal distribution
avg
=
T
.
scalar
()
out
=
srng
.
normal
((),
avg
=
avg
)
assert_raises
(
theano
.
gradient
.
NullTypeGradError
,
theano
.
grad
,
out
,
avg
)
std
=
T
.
scalar
()
out
=
srng
.
normal
((),
avg
=
0
,
std
=
std
)
assert_raises
(
theano
.
gradient
.
NullTypeGradError
,
theano
.
grad
,
out
,
std
)
out
=
srng
.
normal
((),
avg
=
avg
,
std
=
std
)
assert_raises
(
theano
.
gradient
.
NullTypeGradError
,
theano
.
grad
,
out
,
(
avg
,
std
))
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
rng
=
MRG_RandomStreams
(
np
.
random
.
randint
(
2147462579
))
rng
=
MRG_RandomStreams
(
np
.
random
.
randint
(
2147462579
))
print
(
theano
.
__file__
)
print
(
theano
.
__file__
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论