Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
cff00750
提交
cff00750
authored
10月 17, 2012
作者:
Olivier Delalleau
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1015 from lamblin/fix_sparse_int32
Make sure sparse.dot returns the right dtype
上级
99726028
92a69633
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
25 行增加
和
1 行删除
+25
-1
basic.py
theano/sparse/basic.py
+1
-1
test_basic.py
theano/sparse/tests/test_basic.py
+24
-0
没有找到文件。
theano/sparse/basic.py
浏览文件 @
cff00750
...
...
@@ -3109,7 +3109,7 @@ class Dot(gof.op.Op):
if
x_is_sparse
and
y_is_sparse
:
rval
=
rval
.
toarray
()
out
[
0
]
=
rval
out
[
0
]
=
theano
.
_asarray
(
rval
,
dtype
=
node
.
outputs
[
0
]
.
dtype
)
def
grad
(
self
,
(
x
,
y
),
(
gz
,)):
assert
_is_sparse_variable
(
x
)
or
_is_sparse_variable
(
y
)
...
...
theano/sparse/tests/test_basic.py
浏览文件 @
cff00750
...
...
@@ -1031,6 +1031,7 @@ class DotTests(unittest.TestCase):
def
setUp
(
self
):
x_size
=
(
10
,
100
)
y_size
=
(
100
,
1000
)
utt
.
seed_rng
()
self
.
x_csr
=
scipy
.
sparse
.
csr_matrix
(
numpy
.
random
.
binomial
(
1
,
0.5
,
x_size
),
dtype
=
theano
.
config
.
floatX
)
...
...
@@ -1136,6 +1137,29 @@ class DotTests(unittest.TestCase):
d_numpy
=
a_val
*
b
.
get_value
()
assert
numpy
.
allclose
(
d_theano
,
d_numpy
)
def
test_int32_dtype
(
self
):
# Reported on the theano-user mailing-list:
# https://groups.google.com/d/msg/theano-users/MT9ui8LtTsY/rwatwEF9zWAJ
size
=
9
intX
=
'int32'
C
=
tensor
.
matrix
(
'C'
,
dtype
=
intX
)
I
=
tensor
.
matrix
(
'I'
,
dtype
=
intX
)
fI
=
I
.
flatten
()
data
=
tensor
.
ones_like
(
fI
)
indptr
=
tensor
.
arange
(
data
.
shape
[
0
]
+
1
)
m1
=
sparse
.
CSR
(
data
,
fI
,
indptr
,
(
8
,
size
))
m2
=
sparse
.
dot
(
m1
,
C
)
y
=
m2
.
reshape
(
shape
=
(
2
,
4
,
9
),
ndim
=
3
)
f
=
theano
.
function
(
inputs
=
[
I
,
C
],
outputs
=
y
)
i
=
numpy
.
asarray
([[
4
,
3
,
7
,
7
],
[
2
,
8
,
4
,
5
]],
dtype
=
intX
)
a
=
numpy
.
asarray
(
numpy
.
random
.
randint
(
0
,
100
,
(
size
,
size
)),
dtype
=
intX
)
f
(
i
,
a
)
class
UsmmTests
(
unittest
.
TestCase
):
""" Test the Usmm and UsmmCscDense class and related optimization """
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论