Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
2b076111
提交
2b076111
authored
11月 24, 2014
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make MulSS and AddSS support mixed input format.
I do not force the grad to be the same format. This would require conversion. I do not think we always enforce this already, so I do not want to enforce that now.
上级
2f29cf86
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
5 行增加
和
10 行删除
+5
-10
basic.py
theano/sparse/basic.py
+0
-6
test_basic.py
theano/sparse/tests/test_basic.py
+5
-4
没有找到文件。
theano/sparse/basic.py
浏览文件 @
2b076111
...
@@ -1877,8 +1877,6 @@ class AddSS(gof.op.Op):
...
@@ -1877,8 +1877,6 @@ class AddSS(gof.op.Op):
assert
x
.
format
in
[
"csr"
,
"csc"
]
assert
x
.
format
in
[
"csr"
,
"csc"
]
assert
y
.
format
in
[
"csr"
,
"csc"
]
assert
y
.
format
in
[
"csr"
,
"csc"
]
out_dtype
=
scalar
.
upcast
(
x
.
type
.
dtype
,
y
.
type
.
dtype
)
out_dtype
=
scalar
.
upcast
(
x
.
type
.
dtype
,
y
.
type
.
dtype
)
if
x
.
type
.
format
!=
y
.
type
.
format
:
raise
NotImplementedError
()
return
gof
.
Apply
(
self
,
return
gof
.
Apply
(
self
,
[
x
,
y
],
[
x
,
y
],
[
SparseType
(
dtype
=
out_dtype
,
[
SparseType
(
dtype
=
out_dtype
,
...
@@ -2130,10 +2128,6 @@ class MulSS(gof.op.Op):
...
@@ -2130,10 +2128,6 @@ class MulSS(gof.op.Op):
assert
x
.
format
in
[
"csr"
,
"csc"
]
assert
x
.
format
in
[
"csr"
,
"csc"
]
assert
y
.
format
in
[
"csr"
,
"csc"
]
assert
y
.
format
in
[
"csr"
,
"csc"
]
out_dtype
=
scalar
.
upcast
(
x
.
type
.
dtype
,
y
.
type
.
dtype
)
out_dtype
=
scalar
.
upcast
(
x
.
type
.
dtype
,
y
.
type
.
dtype
)
if
x
.
type
.
format
!=
y
.
type
.
format
:
raise
NotImplementedError
(
"MulSS not supported for differing types. "
"Got
%
s and
%
s."
%
(
str
(
x
.
type
),
str
(
y
.
type
)))
return
gof
.
Apply
(
self
,
[
x
,
y
],
return
gof
.
Apply
(
self
,
[
x
,
y
],
[
SparseType
(
dtype
=
out_dtype
,
[
SparseType
(
dtype
=
out_dtype
,
format
=
x
.
type
.
format
format
=
x
.
type
.
format
...
...
theano/sparse/tests/test_basic.py
浏览文件 @
2b076111
...
@@ -16,6 +16,7 @@ from theano import sparse
...
@@ -16,6 +16,7 @@ from theano import sparse
from
theano
import
compile
,
config
,
gof
from
theano
import
compile
,
config
,
gof
from
theano.sparse
import
enable_sparse
from
theano.sparse
import
enable_sparse
from
theano.gof.python25
import
all
,
any
,
product
from
theano.gof.python25
import
all
,
any
,
product
from
theano.gof.python25
import
product
as
itertools_product
from
theano.tensor.basic
import
_allclose
from
theano.tensor.basic
import
_allclose
if
not
enable_sparse
:
if
not
enable_sparse
:
...
@@ -520,17 +521,18 @@ class T_AddMul(unittest.TestCase):
...
@@ -520,17 +521,18 @@ class T_AddMul(unittest.TestCase):
def
_testSS
(
self
,
op
,
array1
=
numpy
.
array
([[
1.
,
0
],
[
3
,
0
],
[
0
,
6
]]),
def
_testSS
(
self
,
op
,
array1
=
numpy
.
array
([[
1.
,
0
],
[
3
,
0
],
[
0
,
6
]]),
array2
=
numpy
.
asarray
([[
0
,
2.
],
[
0
,
4
],
[
5
,
0
]])):
array2
=
numpy
.
asarray
([[
0
,
2.
],
[
0
,
4
],
[
5
,
0
]])):
for
mtype
in
_mtypes
:
for
mtype
1
,
mtype2
in
itertools_product
(
_mtypes
,
_mtypes
)
:
for
dtype1
,
dtype2
in
[(
'float64'
,
'int8'
),
for
dtype1
,
dtype2
in
[(
'float64'
,
'int8'
),
(
'int8'
,
'float64'
),
(
'int8'
,
'float64'
),
(
'float64'
,
'float64'
),
]:
]:
a
=
mtype
(
array1
)
.
astype
(
dtype1
)
a
=
mtype
1
(
array1
)
.
astype
(
dtype1
)
aR
=
as_sparse_variable
(
a
)
aR
=
as_sparse_variable
(
a
)
self
.
assertFalse
(
aR
.
data
is
a
)
self
.
assertFalse
(
aR
.
data
is
a
)
self
.
assertTrue
(
_is_sparse
(
a
))
self
.
assertTrue
(
_is_sparse
(
a
))
self
.
assertTrue
(
_is_sparse_variable
(
aR
))
self
.
assertTrue
(
_is_sparse_variable
(
aR
))
b
=
mtype
(
array2
)
.
astype
(
dtype2
)
b
=
mtype
2
(
array2
)
.
astype
(
dtype2
)
bR
=
as_sparse_variable
(
b
)
bR
=
as_sparse_variable
(
b
)
self
.
assertFalse
(
bR
.
data
is
b
)
self
.
assertFalse
(
bR
.
data
is
b
)
self
.
assertTrue
(
_is_sparse
(
b
))
self
.
assertTrue
(
_is_sparse
(
b
))
...
@@ -540,7 +542,6 @@ class T_AddMul(unittest.TestCase):
...
@@ -540,7 +542,6 @@ class T_AddMul(unittest.TestCase):
self
.
assertTrue
(
_is_sparse_variable
(
apb
))
self
.
assertTrue
(
_is_sparse_variable
(
apb
))
self
.
assertTrue
(
apb
.
type
.
format
==
aR
.
type
.
format
,
apb
.
type
.
format
)
self
.
assertTrue
(
apb
.
type
.
format
==
aR
.
type
.
format
,
apb
.
type
.
format
)
self
.
assertTrue
(
apb
.
type
.
format
==
bR
.
type
.
format
,
apb
.
type
.
format
)
val
=
eval_outputs
([
apb
])
val
=
eval_outputs
([
apb
])
self
.
assertTrue
(
val
.
shape
==
(
3
,
2
))
self
.
assertTrue
(
val
.
shape
==
(
3
,
2
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论