Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
04cf990b
提交
04cf990b
authored
2月 08, 2017
作者:
affanv14
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
changed grad to L_op for remaining functions
上级
e57b752e
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
11 行增加
和
15 行删除
+11
-15
basic.py
theano/scalar/basic.py
+11
-15
没有找到文件。
theano/scalar/basic.py
浏览文件 @
04cf990b
...
...
@@ -1194,10 +1194,9 @@ class LogicalComparison(BinaryScalarOp):
def
output_types
(
self
,
*
input_dtypes
):
return
[
bool
]
if
getattr
(
self
,
'bool'
,
False
)
else
[
int8
]
def
grad
(
self
,
in
puts
,
output_gradients
):
def
L_op
(
self
,
inputs
,
out
puts
,
output_gradients
):
x
,
y
=
inputs
out
=
self
(
x
,
y
)
assert
out
.
type
==
bool
assert
outputs
[
0
]
.
type
==
bool
return
[
x
.
zeros_like
()
.
astype
(
theano
.
config
.
floatX
),
y
.
zeros_like
()
.
astype
(
theano
.
config
.
floatX
)]
...
...
@@ -1436,7 +1435,7 @@ class InRange(LogicalComparison):
else
:
return
elem
.
zeros_like
()
def
grad
(
self
,
in
puts
,
gout
):
def
L_op
(
self
,
inputs
,
out
puts
,
gout
):
(
x
,
low
,
hi
)
=
inputs
(
gz
,)
=
gout
grads
=
[]
...
...
@@ -1605,7 +1604,7 @@ class Maximum(BinaryScalarOp):
return
(
'
%(z)
s = ((
%(y)
s)>(
%(x)
s)? (
%(y)
s): '
'((
%(x)
s)>=(
%(y)
s)? (
%(x)
s): nan("")));'
%
locals
())
def
grad
(
self
,
in
puts
,
gout
):
def
L_op
(
self
,
inputs
,
out
puts
,
gout
):
(
x
,
y
)
=
inputs
(
gz
,)
=
gout
if
gz
.
type
in
complex_types
:
...
...
@@ -1613,14 +1612,12 @@ class Maximum(BinaryScalarOp):
# but the gradient for complex is not.
raise
NotImplementedError
()
output
=
self
(
x
,
y
)
if
output
.
type
in
discrete_types
:
if
outputs
[
0
]
.
type
in
discrete_types
:
return
[
x
.
zeros_like
()
.
astype
(
theano
.
config
.
floatX
),
y
.
zeros_like
()
.
astype
(
theano
.
config
.
floatX
)]
gx
=
eq
(
output
,
x
)
*
gz
gy
=
eq
(
output
,
y
)
*
gz
gx
=
eq
(
output
s
[
0
]
,
x
)
*
gz
gy
=
eq
(
output
s
[
0
]
,
y
)
*
gz
return
(
gx
,
gy
)
maximum
=
Maximum
(
upcast_out
,
name
=
'maximum'
)
...
...
@@ -1643,7 +1640,7 @@ class Minimum(BinaryScalarOp):
return
(
'
%(z)
s = ((
%(y)
s)<(
%(x)
s)? (
%(y)
s): '
'((
%(x)
s)<=(
%(y)
s)? (
%(x)
s): nan("")));'
%
locals
())
def
grad
(
self
,
in
puts
,
gout
):
def
L_op
(
self
,
inputs
,
out
puts
,
gout
):
(
x
,
y
)
=
inputs
(
gz
,)
=
gout
if
gz
.
type
in
complex_types
:
...
...
@@ -1651,12 +1648,11 @@ class Minimum(BinaryScalarOp):
# but the gradient for complex is not.
raise
NotImplementedError
()
output
=
minimum
(
x
,
y
)
if
output
.
type
in
discrete_types
:
if
outputs
[
0
]
.
type
in
discrete_types
:
return
[
x
.
zeros_like
()
.
astype
(
theano
.
config
.
floatX
),
y
.
zeros_like
()
.
astype
(
theano
.
config
.
floatX
)]
gx
=
eq
(
output
,
x
)
*
gz
gy
=
eq
(
output
,
y
)
*
gz
gx
=
eq
(
output
s
[
0
]
,
x
)
*
gz
gy
=
eq
(
output
s
[
0
]
,
y
)
*
gz
return
(
gx
,
gy
)
minimum
=
Minimum
(
upcast_out
,
name
=
'minimum'
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论