Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
35447565
提交
35447565
authored
8月 03, 2012
作者:
Nicolas Bouchard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More corrections.
上级
bb5a2ee7
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
33 行增加
和
26 行删除
+33
-26
sparse.txt
doc/tutorial/sparse.txt
+33
-26
没有找到文件。
doc/tutorial/sparse.txt
浏览文件 @
35447565
...
...
@@ -73,9 +73,12 @@ tutorial:
CSC Matrix
----------
In the *Compressed Sparse Column* format, ``indices`` stands for the indices
of the data along the column and ``indptr`` stands for the column index of the
matrix. The following example builds a matrix and returns its columns.
In the *Compressed Sparse Column* format, ``indices`` stands for the column index
of the data and ``indptr`` tells where the column starts in the ``data`` and in the
``indices`` attributes. ``indptr`` can be tought as giving the slice which must be
applied to the other attribute in order to get each column of the matrix. The following
example builds a matrix and returns its columns. It prints the i-th column indexes in the
first list and their corresponding value in the second list.
>>> data = np.asarray([7, 8, 9])
>>> indices = np.asarray([0, 1, 2])
...
...
@@ -98,9 +101,12 @@ matrix. The following example builds a matrix and returns its columns.
CSR Matrix
----------
In the *Compressed Sparse Row* format, ``indices`` stands for the indices
of the data along the row and ``indptr`` stands for the row index of the
matrix. The following example builds a matrix and returns its rows.
In the *Compressed Sparse Row* format, ``indices`` stands for the row index
of the data and ``indptr`` tells where the row starts in the ``data`` and in the
``indices`` attributes. ``indptr`` can be tought as giving the slice which must be
applied to the other attribute in order to get each row of the matrix. The following
example builds a matrix and returns its rows. It prints the i-th row indexes in the
first list and their corresponding values in the second list.
>>> data = np.asarray([7, 8, 9])
>>> indices = np.asarray([0, 1, 2])
...
...
@@ -125,22 +131,35 @@ Handling Sparse in Theano
=========================
Most of the ops in Theano depend on the ``format`` of the sparse matrix.
That is why there are two kinds of constructors of sparse variables: ``csc_matrix`` and
``csr_matrix``. These can be called with the usual ``name`` and
``dtype`` parameters, but no ``broadcastable`` flags are allowed. This is forbidden
since the sparse package does not provide any way to handle a number of
dimensions different from two. The set of all accepted ``dtype`` for the sparse
matrices can be found in ``sparse.all_dtypes``.
That is why there are two kinds of constructors of sparse variables:
``csc_matrix`` and ``csr_matrix``. These can be called with the usual
``name`` and ``dtype`` parameters, but no ``broadcastable`` flags are
allowed. This is forbidden since the sparse package, as the SciPy sparse module,
does not provide any way to handle a number of dimensions different from two.
The set of all accepted ``dtype`` for the sparse matrices can be found in
``sparse.all_dtypes``.
>>> sparse.all_dtypes
set(['int32', 'int16', 'float64', 'complex128', 'complex64', 'int64', 'int8', 'float32'])
set(['int8', 'int16', 'int32', 'int64', 'float32', 'float64', 'complex64', 'complex128'])
To and Fro
----------
To move back and forth from a dense matrix to a sparse matrix representation, Theano
provides the ``dense_from_sparse``, ``csr_from_dense`` and
``csc_from_dense`` functions. No additional detail must be provided. Here is
an example that performs a full cycle from sparse to sparse:
>>> x = sparse.csc_matrix(name='x', dtype='float32')
>>> y = sparse.dense_from_sparse(x)
>>> z = sparse.csc_from_dense(y)
Properties and Construction
---------------------------
Although sparse variables do not allow direct access to their properties,
this can be accomplished using the ``csm_properties`` function. This will return
a tuple of one-dimensional ``tensor`` variable that represents the internal characteristics
a tuple of one-dimensional ``tensor`` variable
s
that represents the internal characteristics
of the sparse matrix.
In order to reconstruct a sparse matrix from some properties, the functions ``CSC``
...
...
@@ -167,18 +186,6 @@ the other. Indeed, when calling the ``transpose`` function,
the sparse characteristics of the resulting matrix cannot be the same as the one
provided as input.
To and Fro
----------
To move back and forth from a dense matrix to a sparse matrix representation, Theano
provides the ``dense_from_sparse``, ``csr_from_dense`` and
``csc_from_dense`` functions. No additional detail must be provided. Here is
an example that performs a full cycle from sparse to sparse:
>>> x = sparse.csc_matrix(name='x', dtype='float32')
>>> y = sparse.dense_from_sparse(x)
>>> z = sparse.csc_from_dense(y)
Structured Operation
--------------------
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论