Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
74b1abaa
提交
74b1abaa
authored
2月 18, 2022
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
2月 22, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix broken dtype checks in aesara.scalar.basic
上级
7d6dfcb4
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
11 行增加
和
9 行删除
+11
-9
basic.py
aesara/scalar/basic.py
+11
-9
没有找到文件。
aesara/scalar/basic.py
浏览文件 @
74b1abaa
...
...
@@ -757,6 +757,8 @@ discrete_types = (bool,) + integer_types
continuous_types
=
float_types
+
complex_types
all_types
=
discrete_types
+
continuous_types
discrete_dtypes
=
tuple
(
t
.
dtype
for
t
in
discrete_types
)
class
_scalar_py_operators
:
# So that we can simplify checking code when we have a mixture of Scalar
...
...
@@ -1596,7 +1598,7 @@ class Switch(ScalarOp):
first_part
=
switch
(
cond
,
gz
,
0.0
)
second_part
=
switch
(
cond
,
0.0
,
gz
)
if
outputs
[
0
]
.
type
.
dtype
in
discrete_types
:
if
outputs
[
0
]
.
type
in
discrete_types
:
first_part
=
0.0
second_part
=
0.0
...
...
@@ -1991,7 +1993,7 @@ class TrueDiv(BinaryScalarOp):
def
impl
(
self
,
x
,
y
):
x
=
np
.
asarray
(
x
)
y
=
np
.
asarray
(
y
)
if
all
(
a
.
dtype
in
discrete_types
for
a
in
(
x
,
y
)):
if
all
(
a
.
dtype
in
discrete_
d
types
for
a
in
(
x
,
y
)):
return
np
.
sctypeDict
[
config
.
floatX
](
float
(
x
)
/
y
)
else
:
return
x
/
y
...
...
@@ -2030,7 +2032,7 @@ class TrueDiv(BinaryScalarOp):
# This is different from it not being connected
# to the output; x/y is still a function of x
# and y; it's just a step function.
if
all
(
a
.
dtype
in
discrete_types
for
a
in
(
x
,
y
)):
if
all
(
a
.
dtype
in
discrete_
d
types
for
a
in
(
x
,
y
)):
return
[
x
.
zeros_like
(),
y
.
zeros_like
()]
first_part
=
gz
/
y
...
...
@@ -2255,7 +2257,7 @@ class Mod(BinaryScalarOp):
def
L_op
(
self
,
inputs
,
outputs
,
gout
):
(
x
,
y
)
=
inputs
(
gz
,)
=
gout
if
outputs
[
0
]
.
type
.
dtype
in
discrete_types
:
if
outputs
[
0
]
.
type
in
discrete_types
:
# The gradient does not flow in if the output is discrete
return
[
x
.
zeros_like
(
dtype
=
config
.
floatX
),
...
...
@@ -2619,7 +2621,7 @@ class Sgn(UnaryScalarOp):
(
gz
,)
=
gout
rval
=
x
.
zeros_like
()
if
rval
.
type
.
dtype
in
discrete_types
:
if
rval
.
type
in
discrete_types
:
rval
=
rval
.
astype
(
config
.
floatX
)
return
[
rval
]
...
...
@@ -2660,7 +2662,7 @@ class Ceil(UnaryScalarOp):
(
gz
,)
=
gout
rval
=
x
.
zeros_like
()
if
rval
.
type
.
dtype
in
discrete_types
:
if
rval
.
type
in
discrete_types
:
rval
=
rval
.
astype
(
config
.
floatX
)
return
[
rval
]
...
...
@@ -2686,7 +2688,7 @@ class Floor(UnaryScalarOp):
(
gz
,)
=
gout
rval
=
x
.
zeros_like
()
if
rval
.
type
.
dtype
in
discrete_types
:
if
rval
.
type
in
discrete_types
:
rval
=
rval
.
astype
(
config
.
floatX
)
return
[
rval
]
...
...
@@ -2740,7 +2742,7 @@ class RoundHalfToEven(UnaryScalarOp):
(
gz
,)
=
gout
rval
=
x
.
zeros_like
()
if
rval
.
type
.
dtype
in
discrete_types
:
if
rval
.
type
in
discrete_types
:
rval
=
rval
.
astype
(
config
.
floatX
)
return
[
rval
]
...
...
@@ -2826,7 +2828,7 @@ class RoundHalfAwayFromZero(UnaryScalarOp):
(
gz
,)
=
gout
rval
=
x
.
zeros_like
()
if
rval
.
type
.
dtype
in
discrete_types
:
if
rval
.
type
in
discrete_types
:
rval
=
rval
.
astype
(
config
.
floatX
)
return
[
rval
]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论