Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b9854ee7
提交
b9854ee7
authored
9月 25, 2017
作者:
abergeron
提交者:
GitHub
9月 25, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5641 from khaotik/ofg_lop
L_op for OpFromGraph
上级
2ecf9f1d
62d96903
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
29 行增加
和
1 行删除
+29
-1
builders.py
theano/compile/builders.py
+0
-0
test_builders.py
theano/compile/tests/test_builders.py
+29
-1
没有找到文件。
theano/compile/builders.py
浏览文件 @
b9854ee7
差异被折叠。
点击展开。
theano/compile/tests/test_builders.py
浏览文件 @
b9854ee7
...
...
@@ -163,7 +163,8 @@ class T_OpFromGraph(unittest_tools.InferShapeTester):
w
,
b
=
T
.
vectors
(
'wb'
)
# we make the 3rd gradient default (no override)
op_linear
=
cls_ofg
([
x
,
w
,
b
],
[
x
*
w
+
b
],
grad_overrides
=
[
go1
,
go2
,
'default'
])
op_linear
=
cls_ofg
(
[
x
,
w
,
b
],
[
x
*
w
+
b
],
grad_overrides
=
[
go1
,
go2
,
'default'
])
xx
,
ww
,
bb
=
T
.
vector
(
'xx'
),
T
.
vector
(
'yy'
),
T
.
vector
(
'bb'
)
zz
=
T
.
sum
(
op_linear
(
xx
,
ww
,
bb
))
dx
,
dw
,
db
=
T
.
grad
(
zz
,
[
xx
,
ww
,
bb
])
...
...
@@ -191,6 +192,33 @@ class T_OpFromGraph(unittest_tools.InferShapeTester):
assert
isinstance
(
dw2
.
type
,
NullType
)
assert
isinstance
(
db2
.
type
,
DisconnectedType
)
@test_params
def
test_lop_override
(
self
,
cls_ofg
):
x
=
T
.
vector
()
y
=
1.
/
(
1.
+
T
.
exp
(
-
x
))
def
lop_ov
(
inps
,
outs
,
grads
):
y_
,
=
outs
dedy_
,
=
grads
return
[
2.
*
y_
*
(
1.
-
y_
)
*
dedy_
]
y_
,
dedy
=
T
.
vector
(),
T
.
vector
()
op_lop_ov
=
cls_ofg
([
x
,
y_
,
dedy
],
[
2.
*
y_
*
(
1.
-
y_
)
*
dedy
])
xx
=
T
.
vector
()
yy1
=
T
.
sum
(
T
.
nnet
.
sigmoid
(
xx
))
gyy1
=
2.
*
T
.
grad
(
yy1
,
xx
)
for
ov
in
[
lop_ov
,
op_lop_ov
]:
op
=
cls_ofg
([
x
],
[
y
],
lop_overrides
=
ov
)
yy2
=
T
.
sum
(
op
(
xx
))
gyy2
=
T
.
grad
(
yy2
,
xx
)
fn
=
function
([
xx
],
[
gyy1
,
gyy2
])
xval
=
np
.
random
.
rand
(
32
)
.
astype
(
config
.
floatX
)
y1val
,
y2val
=
fn
(
xval
)
assert
np
.
allclose
(
y1val
,
y2val
)
@test_params
def
test_rop
(
self
,
cls_ofg
):
a
=
T
.
vector
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论