Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e16273c9
提交
e16273c9
authored
8月 06, 2015
作者:
Iban Harlouchet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
numpydoc for theano/tensor/nnet/conv3d2d.py
上级
61280f0a
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
68 行增加
和
32 行删除
+68
-32
conv3d2d.py
theano/tensor/nnet/conv3d2d.py
+68
-32
没有找到文件。
theano/tensor/nnet/conv3d2d.py
浏览文件 @
e16273c9
...
...
@@ -6,10 +6,13 @@ import theano.sandbox.cuda as cuda
def
get_diagonal_subtensor_view
(
x
,
i0
,
i1
):
"""Helper function for DiagonalSubtensor and
IncDiagonalSubtensor
"""
Helper function for DiagonalSubtensor and IncDiagonalSubtensor.
Notes
-----
It returns a partial view of x, not a partial copy.
:note: it return a partial view of x, not a partial copy.
"""
# We have to cast i0 and i0 to int because python 2.4 (and maybe later)
# do not support indexing with 0-dim, 'int*' ndarrays.
...
...
@@ -27,13 +30,24 @@ def get_diagonal_subtensor_view(x, i0, i1):
class
DiagonalSubtensor
(
Op
):
"""Return a form a nd diagonal subtensor.
:param x: n-d tensor
:param i0: axis index in x
:param i1: axis index in x
:note: Work on the GPU.
"""
Return a form a nd diagonal subtensor.
Parameters
----------
x
n-d tensor
i0
Axis index in x
i1
Axis index in x
Notes
-----
Work on the GPU.
Extended summary
----------------
``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,
...
...
@@ -73,6 +87,7 @@ class DiagonalSubtensor(Op):
see what's necessary at that point.
"""
__props__
=
(
"inplace"
,)
def
__str__
(
self
):
...
...
@@ -111,8 +126,10 @@ diagonal_subtensor = DiagonalSubtensor(False)
class
IncDiagonalSubtensor
(
Op
):
"""
The gradient of DiagonalSubtensor
The gradient of DiagonalSubtensor.
"""
__props__
=
(
"inplace"
,)
def
__str__
(
self
):
...
...
@@ -153,26 +170,39 @@ inc_diagonal_subtensor = IncDiagonalSubtensor(False)
def
conv3d
(
signals
,
filters
,
signals_shape
=
None
,
filters_shape
=
None
,
border_mode
=
'valid'
):
"""Convolve spatio-temporal filters with a movie.
"""
Convolve spatio-temporal filters with a movie.
It flips the filters.
:param signals: timeseries of images whose pixels have color channels.
shape: [Ns, Ts, C, Hs, Ws]
:param filters: spatio-temporal filters
shape: [Nf, Tf, C, Hf, Wf]
:param signals_shape: None or a tuple/list with the shape of signals
:param filters_shape: None or a tuple/list with the shape of filters
:param border_mode: The only one tested is 'valid'.
:note: Another way to define signals: (batch, time, in channel, row, column)
Another way to define filters: (out channel,time,in channel, row, column)
:note: For the GPU, you can use this implementation or
:func:`conv3d_fft <theano.sandbox.cuda.fftconv.conv3d_fft>`.
:see: Someone made a script that shows how to swap the axes between
both 3d convolution implementations in Theano. See the last
`attachment <https://groups.google.com/d/msg/theano-users/1S9_bZgHxVw/0cQR9a4riFUJ>`_.
Parameters
----------
signals
Timeseries of images whose pixels have color channels.
Shape: [Ns, Ts, C, Hs, Ws].
filters
Spatio-temporal filters.
Shape: [Nf, Tf, C, Hf, Wf].
signals_shape
None or a tuple/list with the shape of signals.
filters_shape
None or a tuple/list with the shape of filters.
border_mode
The only one tested is 'valid'.
Notes
-----
Another way to define signals: (batch, time, in channel, row, column)
Another way to define filters: (out channel,time,in channel, row, column)
For the GPU, you can use this implementation or
:func:`conv3d_fft <theano.sandbox.cuda.fftconv.conv3d_fft>`.
See Also
--------
Someone made a script that shows how to swap the axes between
both 3d convolution implementations in Theano. See the last
`attachment <https://groups.google.com/d/msg/theano-users/1S9_bZgHxVw/0cQR9a4riFUJ>`_.
"""
...
...
@@ -264,7 +294,8 @@ def conv3d(signals, filters,
def
make_gpu_optimizer
(
op
,
to_gpu
):
"""This function create optimizer that move some inputs to the GPU
"""
This function create optimizer that move some inputs to the GPU
for op that work on both CPU and GPU.
The op object is created by calling op(), so good default value
...
...
@@ -272,8 +303,12 @@ def make_gpu_optimizer(op, to_gpu):
We suppose the same op work with CPU and GPU inputs.
:param op: the op that support GPU inputs
:param to_gpu: a list of op inputs that are moved to the GPU.
Parameters
----------
op
The op that support GPU inputs.
to_gpu
A list of op inputs that are moved to the GPU.
"""
@theano.gof.local_optimizer
([
op
,
cuda
.
gpu_from_host
])
...
...
@@ -281,6 +316,7 @@ def make_gpu_optimizer(op, to_gpu):
"""
op(host_from_gpu()) -> host_from_gpu(op)
gpu_from_host(op) -> op(gpu_from_host)
"""
if
isinstance
(
node
.
op
,
op
):
# op(host_from_gpu()) -> host_from_gpu(op)
...
...
@@ -314,7 +350,7 @@ if cuda.cuda_available:
@theano.gof.local_optimizer
([
DiagonalSubtensor
,
IncDiagonalSubtensor
])
def
local_inplace_DiagonalSubtensor
(
node
):
"""
also work for IncDiagonalSubtensor
"""
"""
Also work for IncDiagonalSubtensor.
"""
if
(
isinstance
(
node
.
op
,
(
DiagonalSubtensor
,
IncDiagonalSubtensor
))
and
not
node
.
op
.
inplace
):
new_op
=
node
.
op
.
__class__
(
inplace
=
True
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论