Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d66d4c92
提交
d66d4c92
authored
10月 08, 2013
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add method SparseVariable.toarray()
上级
970c704d
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
22 行增加
和
12 行删除
+22
-12
index.txt
doc/library/sparse/index.txt
+1
-0
basic.py
theano/sparse/basic.py
+2
-0
test_basic.py
theano/sparse/tests/test_basic.py
+19
-12
没有找到文件。
doc/library/sparse/index.txt
浏览文件 @
d66d4c92
...
@@ -123,6 +123,7 @@ List of Implemented Operations
...
@@ -123,6 +123,7 @@ List of Implemented Operations
Both grad are implemented. Structured by default.
Both grad are implemented. Structured by default.
- :class:`SparseFromDense <theano.sparse.basic.SparseFromDense>` and ``csr_from_dense``, ``csc_from_dense``.
- :class:`SparseFromDense <theano.sparse.basic.SparseFromDense>` and ``csr_from_dense``, ``csc_from_dense``.
The grad implemented is structured.
The grad implemented is structured.
- Theano SparseVariable object have a method ``toarray()`` that is the same as ``dense_from_sparse``.
- Construction of Sparses and their Properties
- Construction of Sparses and their Properties
- :class:`CSM <theano.sparse.basic.CSM>` and ``CSC``, ``CSR`` to construct a matrix.
- :class:`CSM <theano.sparse.basic.CSM>` and ``CSC``, ``CSR`` to construct a matrix.
...
...
theano/sparse/basic.py
浏览文件 @
d66d4c92
...
@@ -300,6 +300,8 @@ class _sparse_py_operators:
...
@@ -300,6 +300,8 @@ class _sparse_py_operators:
# def _as_TensorVariable(self):
# def _as_TensorVariable(self):
# return dense_from_sparse(self)
# return dense_from_sparse(self)
def
toarray
(
self
):
return
dense_from_sparse
(
self
)
shape
=
property
(
lambda
self
:
tensor
.
shape
(
dense_from_sparse
(
self
)))
shape
=
property
(
lambda
self
:
tensor
.
shape
(
dense_from_sparse
(
self
)))
# don't worry!
# don't worry!
# the plan is that the ShapeFeature in tensor.opt will do shape propagation
# the plan is that the ShapeFeature in tensor.opt will do shape propagation
...
...
theano/sparse/tests/test_basic.py
浏览文件 @
d66d4c92
...
@@ -708,18 +708,25 @@ class T_conversion(unittest.TestCase):
...
@@ -708,18 +708,25 @@ class T_conversion(unittest.TestCase):
self
.
assertTrue
(
str
(
val
.
dtype
)
==
'float64'
)
self
.
assertTrue
(
str
(
val
.
dtype
)
==
'float64'
)
self
.
assertTrue
(
val
.
format
==
'csr'
)
self
.
assertTrue
(
val
.
format
==
'csr'
)
if
1
:
def
test_dense_from_sparse
(
self
):
def
test2
(
self
):
#call dense_from_sparse
#call dense_from_sparse
for
t
in
_mtypes
:
for
t
in
_mtypes
:
s
=
t
(
scipy
.
sparse
.
identity
(
5
))
s
=
t
(
scipy
.
sparse
.
identity
(
5
))
s
=
as_sparse_variable
(
s
)
d
=
dense_from_sparse
(
s
)
d
=
dense_from_sparse
(
s
)
# s should be copied into the graph as a constant
val
=
eval_outputs
([
d
])
s
[
0
,
0
]
=
3.0
# changes s, but not the copy
self
.
assertTrue
(
str
(
val
.
dtype
)
==
s
.
dtype
)
val
=
eval_outputs
([
d
])
self
.
assertTrue
(
numpy
.
all
(
val
[
0
]
==
[
1
,
0
,
0
,
0
,
0
]))
return
self
.
assertTrue
(
str
(
val
.
dtype
)
==
s
.
dtype
)
def
test_todense
(
self
):
self
.
assertTrue
(
numpy
.
all
(
val
[
0
]
==
[
1
,
0
,
0
,
0
,
0
]))
#call sparse_var.todense()
for
t
in
_mtypes
:
s
=
t
(
scipy
.
sparse
.
identity
(
5
))
s
=
as_sparse_variable
(
s
)
d
=
s
.
toarray
()
val
=
eval_outputs
([
d
])
self
.
assertTrue
(
str
(
val
.
dtype
)
==
s
.
dtype
)
self
.
assertTrue
(
numpy
.
all
(
val
[
0
]
==
[
1
,
0
,
0
,
0
,
0
]))
@staticmethod
@staticmethod
def
check_format_ndim
(
format
,
ndim
):
def
check_format_ndim
(
format
,
ndim
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论