Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
37c91213
提交
37c91213
authored
2月 25, 2009
作者:
Joseph Turian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More sparse documentation
上级
6f475869
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
31 行增加
和
2 行删除
+31
-2
internal.txt
doc/doc/internal.txt
+1
-1
sparse.txt
doc/doc/sparse.txt
+27
-0
basic.py
theano/sparse/basic.py
+3
-1
没有找到文件。
doc/doc/internal.txt
浏览文件 @
37c91213
...
...
@@ -16,7 +16,7 @@ For example::
:api:`function <theano.compile.function>`
You can also use
:api:`path-to-symbol
` directly.
You can also use
``:api:\`path-to-symbol\``
` directly.
If you are lazy, you can try::
...
...
doc/doc/sparse.txt
浏览文件 @
37c91213
...
...
@@ -81,3 +81,30 @@ Several things should be learned from the above example:
3 contains sp.data[2:3], i.e. the third non-zero value.
TODO: Rewrite this documentation to do things in a smarter way.
:api:`TrueDot` vs. :api:`StructuredDot`
----------------------------------------
Often when you use a sparse matrix it is because there is a meaning to the
structure of non-zeros. The gradient on terms outside that structure
has no meaning, so it is computationally efficient not to compute them.
StructuredDot is when you want the gradient to have zeroes corresponding to
the sparse entries in the matrix.
TrueDot and Structured dot have different gradients
but their perform functions should be the same.
The gradient of TrueDot can have non-zeros where the sparse matrix had zeros.
The gradient of StructuredDot can't.
Suppose you have ``dot(x,w)`` where ``x`` and ``w`` are square matrices.
If ``w`` is dense, like ``randn((5,5))`` and ``x`` is of full rank (though
potentially sparse, like a diagonal matrix of 1s) then the output will
be dense too. (But i guess the density of the output is a red herring.)
What's important is the density of the gradient on the output.
If the gradient on the output is dense, and ``w`` is dense (as we said it was)
then the True gradient on ``x`` will be dense.
If our dot is a TrueDot, then it will say that the gradient on ``x`` is dense.
If our dot is a StructuredDot, then it will say the gradient on ``x`` is only
defined on the diagonal and ignore the gradients on the off-diagonal.
theano/sparse/basic.py
浏览文件 @
37c91213
...
...
@@ -364,8 +364,10 @@ register_specialize(skip_pack_csc01)
#
# Conversion
#
# convert a sparse matrix to an ndarray
class
DenseFromSparse
(
gof
.
op
.
Op
):
"""
Convert a sparse matrix to an `ndarray`.
"""
sparse_grad
=
True
def
make_node
(
self
,
x
):
x
=
as_sparse
(
x
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论