Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
3a89cde2
提交
3a89cde2
authored
10月 31, 2013
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add doc about conv implementation.
上级
a4fc4e09
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
72 行增加
和
4 行删除
+72
-4
conv.txt
doc/library/tensor/nnet/conv.txt
+12
-2
Conv3D.py
theano/tensor/nnet/Conv3D.py
+5
-0
conv3d2d.py
theano/tensor/nnet/conv3d2d.py
+55
-2
没有找到文件。
doc/library/tensor/nnet/conv.txt
浏览文件 @
3a89cde2
...
@@ -29,9 +29,19 @@ TODO: Give examples for how to use these things! They are pretty complicated.
...
@@ -29,9 +29,19 @@ TODO: Give examples for how to use these things! They are pretty complicated.
- :func:`nnet.conv2d <theano.tensor.nnet.conv.conv2d>`.
- :func:`nnet.conv2d <theano.tensor.nnet.conv.conv2d>`.
- :func:`conv3D <theano.tensor.nnet.Conv3D.conv3D>`.
- :func:`conv3D <theano.tensor.nnet.Conv3D.conv3D>`.
- :func:`conv3d2d <theano.tensor.nnet.conv3d2d.conv3d>`
- :func:`conv3d2d <theano.tensor.nnet.conv3d2d.conv3d>`
Another conv3d implementation that use the conv2d with datareshaping.
Another conv3d implementation that use the conv2d with data
reshaping.
It is faster in some case then conv3d, specificaly on the GPU.
It is faster in some case then conv3d, specificaly on the GPU.
But it support all the gradient cases that conv2d don't implement.
- `Faster conv2d <http://deeplearning.net/software/pylearn2/library/alex.html>`_
This is in Pylearn2, not very documented and use a different
memory layout for the input. It is important to have the input
in the native memory layout, and not use dimshuffle on the
inputs, otherwise you loose much of the speed up. So this is not
a drop in replacement of conv2d.
Normally those are called from the `linear transfrom
<http://deeplearning.net/software/pylearn2/library/linear.html>`_
implementation.
.. autofunction:: theano.tensor.nnet.conv.conv2d
.. autofunction:: theano.tensor.nnet.conv.conv2d
.. autofunction:: theano.tensor.nnet.Conv3D.conv3D
.. autofunction:: theano.tensor.nnet.Conv3D.conv3D
...
...
theano/tensor/nnet/Conv3D.py
浏览文件 @
3a89cde2
...
@@ -562,6 +562,11 @@ conv3D = Conv3D()
...
@@ -562,6 +562,11 @@ conv3D = Conv3D()
:note: The order of dimensions does not correspond to the one in `conv2d`.
:note: The order of dimensions does not correspond to the one in `conv2d`.
This is for optimization.
This is for optimization.
:note: The GPU implementation is very slow. You are better to use
:func:`conv3d2d <theano.tensor.nnet.conv3d2d.conv3d>` that is faster
on GPU.
"""
"""
def
computeH
(
V
,
W
,
b
,
d
):
def
computeH
(
V
,
W
,
b
,
d
):
...
...
theano/tensor/nnet/conv3d2d.py
浏览文件 @
3a89cde2
...
@@ -6,6 +6,12 @@ import theano.sandbox.cuda as cuda
...
@@ -6,6 +6,12 @@ import theano.sandbox.cuda as cuda
def
get_diagonal_subtensor_view
(
x
,
i0
,
i1
):
def
get_diagonal_subtensor_view
(
x
,
i0
,
i1
):
"""Helper function for DiagonalSubtensor and
IncDiagonalSubtensor
:note: it return a partial view of x, not a partial copy.
"""
if
x
.
shape
[
i0
]
<
x
.
shape
[
i1
]:
if
x
.
shape
[
i0
]
<
x
.
shape
[
i1
]:
raise
NotImplementedError
(
'is this allowed?'
)
raise
NotImplementedError
(
'is this allowed?'
)
idx
=
[
slice
(
None
)]
*
x
.
ndim
idx
=
[
slice
(
None
)]
*
x
.
ndim
...
@@ -18,8 +24,51 @@ def get_diagonal_subtensor_view(x, i0, i1):
...
@@ -18,8 +24,51 @@ def get_diagonal_subtensor_view(x, i0, i1):
class
DiagonalSubtensor
(
Op
):
class
DiagonalSubtensor
(
Op
):
"""
"""Return a form a nd diagonal subtensor.
Work on the GPU.
:param x: n-d tensor
:param i0: axis index in x
:param i1: axis index in x
:note: Work on the GPU.
``x`` is some n-dimensional tensor, but this Op only deals with a
matrix-shaped slice, using axes i0 and i1. Without loss of
generality, suppose that ``i0`` picks out our ``row`` dimension,
and i1 the ``column`` dimension.
So the relevant part of ``x`` is some matrix ``u``. Suppose it has 7 rows
and 4 columns::
[ 0 0 0 0 ]
[ 0 0 0 0 ]
[ 0 0 0 0 ]
[ 0 0 0 0 ]
[ 0 0 0 0 ]
[ 0 0 0 0 ]
The view returned by this function is also a matrix. It's a thick,
diagonal ``stripe`` across u that discards the lower left triangle
and the upper right triangle:
[ x 0 0 0 ]
[ x x 0 0 ]
[ x x x 0 ]
[ 0 x x x ]
[ 0 0 x x ]
[ 0 0 0 x ]
In this case the return value would be this view of shape 3x4. The
returned view has the same number of dimensions as the input
``x``, and the only difference is that the shape along dimension
``i0`` has been reduced by ``shape[i1] - 1`` because of the
triangles that got chopped out.
The NotImplementedError is meant to catch the case where shape[i0]
is too small for the stripe to reach across the matrix, in which
case it's not clear what this function should do. Maybe always
raise an error. I'd look back to the call site in the Conv3D to
see what's necessary at that point.
"""
"""
def
__str__
(
self
):
def
__str__
(
self
):
if
self
.
inplace
:
if
self
.
inplace
:
...
@@ -62,6 +111,9 @@ diagonal_subtensor = DiagonalSubtensor(False)
...
@@ -62,6 +111,9 @@ diagonal_subtensor = DiagonalSubtensor(False)
class
IncDiagonalSubtensor
(
Op
):
class
IncDiagonalSubtensor
(
Op
):
"""
The gradient of DiagonalSubtensor
"""
def
__str__
(
self
):
def
__str__
(
self
):
if
self
.
inplace
:
if
self
.
inplace
:
return
"
%
s{inplace}"
%
self
.
__class__
.
__name__
return
"
%
s{inplace}"
%
self
.
__class__
.
__name__
...
@@ -116,6 +168,7 @@ def conv3d(signals, filters,
...
@@ -116,6 +168,7 @@ def conv3d(signals, filters,
:param filters_shape: None or a tuple/list with the shape of filters
:param filters_shape: None or a tuple/list with the shape of filters
:param border_mode: The only one tested is 'valid'.
:param border_mode: The only one tested is 'valid'.
:note: Work on the GPU.
"""
"""
if
isinstance
(
border_mode
,
str
):
if
isinstance
(
border_mode
,
str
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论