Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
755ba97a
提交
755ba97a
authored
7月 27, 2015
作者:
abergeron
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3189 from nouiz/fix_nan
[BUG, TEST] Fix Sng handling of nan and fix related test
上级
e7d00def
08ac04b7
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
33 行增加
和
6 行删除
+33
-6
test_basic_ops.py
theano/sandbox/gpuarray/tests/test_basic_ops.py
+8
-0
type.py
theano/sandbox/gpuarray/type.py
+23
-2
basic.py
theano/scalar/basic.py
+2
-4
test_basic.py
theano/tensor/tests/test_basic.py
+0
-0
没有找到文件。
theano/sandbox/gpuarray/tests/test_basic_ops.py
浏览文件 @
755ba97a
...
...
@@ -384,6 +384,14 @@ class G_reshape(test_basic.T_reshape):
assert
self
.
op
==
GpuReshape
class
G_comparison
(
test_basic
.
test_comparison
):
def
setUp
(
self
):
utt
.
seed_rng
()
self
.
mode
=
mode_with_gpu
self
.
shared
=
gpuarray_shared_constructor
self
.
dtypes
=
[
'float64'
,
'float32'
]
class
G_Join_and_Split
(
test_basic
.
T_Join_and_Split
):
def
setUp
(
self
):
super
(
G_Join_and_Split
,
self
)
.
setUp
()
...
...
theano/sandbox/gpuarray/type.py
浏览文件 @
755ba97a
...
...
@@ -121,7 +121,20 @@ class GpuArrayType(Type):
return
False
if
a
.
typecode
!=
b
.
typecode
:
return
False
return
numpy
.
asarray
(
compare
(
a
,
'=='
,
b
))
.
all
()
a_eq_b
=
numpy
.
asarray
(
compare
(
a
,
'=='
,
b
))
if
a_eq_b
.
all
():
return
True
# maybe the trouble is that there are NaNs
a
=
numpy
.
asarray
(
a
)
b
=
numpy
.
asarray
(
b
)
a_missing
=
numpy
.
isnan
(
a
)
if
a_missing
.
any
():
b_missing
=
numpy
.
isnan
(
b
)
return
numpy
.
all
(
a_eq_b
+
(
a_missing
==
b_missing
))
else
:
return
False
@staticmethod
def
values_eq_approx
(
a
,
b
,
...
...
@@ -157,7 +170,15 @@ class GpuArrayType(Type):
op_tmpl
=
"res[i] = (fabs(
%%(a)
s -
%%(b)
s) <"
"(
%(atol_)
s +
%(rtol_)
s * fabs(
%%(b)
s)))"
%
locals
())
return
numpy
.
asarray
(
res
)
.
all
()
ret
=
numpy
.
asarray
(
res
)
.
all
()
if
ret
:
return
True
# maybe the trouble is that there are NaNs
an
=
numpy
.
asarray
(
a
)
bn
=
numpy
.
asarray
(
b
)
return
tensor
.
TensorType
.
values_eq_approx
(
an
,
bn
,
allow_remove_inf
=
allow_remove_inf
,
allow_remove_nan
=
allow_remove_nan
,
rtol
=
rtol
,
atol
=
atol
)
@staticmethod
def
may_share_memory
(
a
,
b
):
...
...
theano/scalar/basic.py
浏览文件 @
755ba97a
...
...
@@ -1096,8 +1096,6 @@ class EQ(LogicalComparison):
def
c_code
(
self
,
node
,
name
,
inputs
,
outputs
,
sub
):
(
x
,
y
)
=
inputs
(
z
,)
=
outputs
if
node
.
inputs
[
0
]
.
type
in
complex_types
:
raise
NotImplementedError
()
return
"
%(z)
s = (
%(x)
s ==
%(y)
s);"
%
locals
()
eq
=
EQ
()
...
...
@@ -2104,7 +2102,7 @@ class Sgn(UnaryScalarOp):
(
z
,)
=
outputs
type
=
node
.
inputs
[
0
]
.
type
if
type
in
float_types
:
return
"
%(z)
s = (
%(x)
s >= 0) ? (
%(x)
s == 0) ? 0.0 : 1.0 : -1.0;"
%
locals
()
return
'
%(z)
s = (
%(x)
s > 0) ? 1. : ((
%(x)
s < 0) ? -1. : (isnan(
%(x)
s) ? NAN : 0.));'
%
locals
()
if
type
in
int_types
:
return
"
%(z)
s = (
%(x)
s >= 0) ? (
%(x)
s == 0) ? 0 : 1 : -1;"
%
locals
()
raise
TypeError
()
# complex has no sgn
...
...
@@ -2112,7 +2110,7 @@ class Sgn(UnaryScalarOp):
def
c_code_cache_version
(
self
):
s
=
super
(
Sgn
,
self
)
.
c_code_cache_version
()
if
s
:
return
(
3
,)
+
s
return
(
4
,)
+
s
else
:
# if parent is unversioned, we are too
return
s
sgn
=
Sgn
(
same_out_nocomplex
,
name
=
'sgn'
)
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
755ba97a
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论