Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
3e5ae1b2
提交
3e5ae1b2
authored
9月 10, 2012
作者:
Ian Goodfellow
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/int_grad' into int_grad
上级
6d7ad4d6
66be96ea
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
25 行增加
和
1 行删除
+25
-1
op.txt
doc/extending/op.txt
+19
-1
scan_op.py
theano/scan_module/scan_op.py
+6
-0
没有找到文件。
doc/extending/op.txt
浏览文件 @
3e5ae1b2
...
...
@@ -266,6 +266,17 @@ following methods:
Finally, many times in theano, integer valued inputs don't actually affect the elements of
the output, only its shape.
If your function f has both an integer-valued input and an
integer-valued output, then both rules have to be combined:
- If f is defined at (x+epsilon), then the input gradient is
defined. Since f(x+epsilon) would be equal to f(x) almost
everywhere, the gradient should be 0 (first rule).
- If f is only defined where x is an integer, then the gradient
is undefined, regardless of what the gradient with respect to the
output is.
Examples:
1) f(x,y) = dot product between x and y. x and y are integers.
...
...
@@ -278,11 +289,18 @@ following methods:
same as if y were floating point.
3) f(x,y) = argmax of x along axis y.
The gradient with respect to y is undefined, because f(x,y) is not defined for
floating point y. How could you take an argmax along a fractional axis?
floating point y. How could you take an argmax along a fraActional axis?
The gradient with respect to x is 0, because f(x+epsilon, y) = f(x) almost
everywhere.
4) f(x,y) = a vector with y elements, each of which taking on the value x
The grad method should return DisconnectedType()() for y, because the elements of
f don't depend on y. Only the shape of f depends on y. You probably also want to
implement a connection_pattern method to encode this.
5) f(x) = int(x) converts float x into an int. g(y) = float(y) converts an integer y into a float.
If the final cost C = 0.5 * g(y) = 0.5 g(f(x)), then the
gradient with respect to y will be 0.5, even if y is an
integer. However, the gradient with respect to x will be 0,
because the output of f is integer-valued.
.. function:: infer_shape(node, shapes)
...
...
theano/scan_module/scan_op.py
浏览文件 @
3e5ae1b2
...
...
@@ -1305,7 +1305,13 @@ class Scan(PureOp):
# 7.3. compute gradients of the inputs given one output
for
dx
,
out
in
enumerate
(
clean_outputs
):
if
g_outs
[
dx
]
!=
None
:
inner_g_out
=
safe_new
(
g_outs
[
dx
][
0
])
else
:
# We do not have a gradient on this output so we need a
# placeholder, which for now has the same dtype as the
# output
inner_g_out
=
safe_new
(
out
)
###
#### I need to clip the gradient HERE !!
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论