Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7b8ee75b
提交
7b8ee75b
authored
1月 21, 2016
作者:
Sina Honari
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
updating notations and namings
上级
4bd7b623
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
59 行增加
和
53 行删除
+59
-53
abstract_conv.py
theano/tensor/nnet/abstract_conv.py
+59
-53
没有找到文件。
theano/tensor/nnet/abstract_conv.py
浏览文件 @
7b8ee75b
...
@@ -177,21 +177,25 @@ def conv2d(input,
...
@@ -177,21 +177,25 @@ def conv2d(input,
return
conv_op
(
input
,
filters
)
return
conv_op
(
input
,
filters
)
def
deconv
(
input
,
def
conv2d_grad_wrt_inputs
(
output_grad
,
filters
,
filters
,
input_shape
=
None
,
output_grad_shape
=
None
,
output_shape
=
None
,
input_shape
=
None
,
filter_shape
=
None
,
filter_shape
=
None
,
border_mode
=
'valid'
,
border_mode
=
'valid'
,
subsample
=
(
1
,
1
),
subsample
=
(
1
,
1
),
filter_flip
=
True
):
filter_flip
=
True
):
"""This function will build the symbolic graph for deconvoloving a
"""This function builds the symbolic graph for getting the
mini-batch of a stack of 2D inputs with a set of 2D filters (using
gradient of the output of a convolution (namely output_grad)
gradient of convolution), such that it upsamples the input to the
w.r.t the input of the convolution, given a set of 2D filters
desired output resolution.
used by the convolution, such that the output_grad is upsampled
to the input shape.
:type input: symbolic 4D tensor to be upsampled
:param input: mini-batch of feature map stacks, of shape
:type output_grad: symbolic 4D tensor as the output gradient
of the convolution. This is the tensor that will be upsampled
or whose gradient will be taken with respect to the input of
the convolution.
:param output_grad: mini-batch of feature map stacks, of shape
(batch size, input channels, input rows, input columns).
(batch size, input channels, input rows, input columns).
See the optional parameter ``input_shape``.
See the optional parameter ``input_shape``.
...
@@ -200,18 +204,18 @@ def deconv(input,
...
@@ -200,18 +204,18 @@ def deconv(input,
(output channels, input channels, filter rows, filter columns).
(output channels, input channels, filter rows, filter columns).
See the optional parameter ``filter_shape``.
See the optional parameter ``filter_shape``.
:type
input_shape: None, tuple/list of len 4 of int or Constant variable
:type
output_grad_shape: None, tuple/list of len 4 of int or
indicating the shape to be upsampled or whose gradient should be taken
.
Constant variable indicating the shape of the output_grad
.
:param
input_shape: The shape of the input
parameter.
:param
output_grad_shape: The shape of the output_grad
parameter.
Optional, possibly used to choose an optimal implementation.
Optional, possibly used to choose an optimal implementation.
You can give ``None`` for any element of the list to specify that this
You can give ``None`` for any element of the list to specify that this
element is not known at compile time.
element is not known at compile time.
:type
out
put_shape: tuple/list of len 2 of int or Constant variable
:type
in
put_shape: tuple/list of len 2 of int or Constant variable
indicating the row and column size of the
out
put (upsampled) features.
indicating the row and column size of the
in
put (upsampled) features.
:param
out
put_shape: The shape of the input parameter.
:param
in
put_shape: The shape of the input parameter.
Not Optional, since given the
input
_shape and the subsample values,
Not Optional, since given the
output_grad
_shape and the subsample values,
multiple
out
put_shape may be plausible.
multiple
in
put_shape may be plausible.
:type filter_shape: None, tuple/list of len 4 of int or Constant variable
:type filter_shape: None, tuple/list of len 4 of int or Constant variable
:param filter_shape: The shape of the filters parameter.
:param filter_shape: The shape of the filters parameter.
...
@@ -259,32 +263,34 @@ def deconv(input,
...
@@ -259,32 +263,34 @@ def deconv(input,
"""
"""
deconv_op
=
AbstractConv2d_gradInputs
(
imshp
=
out
put_shape
,
deconv_op
=
AbstractConv2d_gradInputs
(
imshp
=
in
put_shape
,
kshp
=
filter_shape
,
kshp
=
filter_shape
,
border_mode
=
border_mode
,
border_mode
=
border_mode
,
subsample
=
subsample
,
subsample
=
subsample
,
filter_flip
=
filter_flip
)
filter_flip
=
filter_flip
)
return
deconv_op
(
filters
,
input
,
output_shape
)
return
deconv_op
(
filters
,
input
,
output_
grad_
shape
)
def
gradW
eights
(
input
,
def
conv2d_grad_wrt_w
eights
(
input
,
output
,
output_grad
,
input_shape
=
None
,
input_shape
=
None
,
output
_shape
=
None
,
output_grad
_shape
=
None
,
filter_shape
=
None
,
filter_shape
=
None
,
border_mode
=
'valid'
,
border_mode
=
'valid'
,
subsample
=
(
1
,
1
),
subsample
=
(
1
,
1
),
filter_flip
=
True
):
filter_flip
=
True
):
"""This function will build the symbolic graph for getting the
"""This function will build the symbolic graph for getting the
gradient of the output of a convolution
layer
w.r.t its wights.
gradient of the output of a convolution
(output_grad)
w.r.t its wights.
:type input: symbolic 4D tensor as in the input in the forward pass
:type input: symbolic 4D tensor as the input of the convolution
in the forward pass
:param input: mini-batch of feature map stacks, of shape
:param input: mini-batch of feature map stacks, of shape
(batch size, input channels, input rows, input columns).
(batch size, input channels, input rows, input columns).
:type output: symbolic 4D tensor as in the output in the forward pass
:type output_grad: symbolic 4D tensor as the gradient output
:param output: mini-batch of feature map stacks, of shape
of the convolution
:param output_grad: mini-batch of feature map stacks, of shape
(batch size, input channels, input rows, input columns).
(batch size, input channels, input rows, input columns).
:type filters: symbolic 4D tensor
:type filters: symbolic 4D tensor
...
@@ -292,8 +298,8 @@ def gradWeights(input,
...
@@ -292,8 +298,8 @@ def gradWeights(input,
(output channels, input channels, filter rows, filter columns).
(output channels, input channels, filter rows, filter columns).
See the optional parameter ``filter_shape``.
See the optional parameter ``filter_shape``.
:type output_shape: None, tuple/list of len 4 of int or Constant variable
:type output_
grad_
shape: None, tuple/list of len 4 of int or Constant variable
:param output_shape: The shape of the input parameter.
:param output_
grad_
shape: The shape of the input parameter.
Optional, possibly used to choose an optimal implementation.
Optional, possibly used to choose an optimal implementation.
You can give ``None`` for any element of the list to specify that this
You can give ``None`` for any element of the list to specify that this
element is not known at compile time.
element is not known at compile time.
...
@@ -301,15 +307,15 @@ def gradWeights(input,
...
@@ -301,15 +307,15 @@ def gradWeights(input,
:type input_shape: tuple/list of len 2 of int or Constant variable
:type input_shape: tuple/list of len 2 of int or Constant variable
indicating the row and column size of the input in the forward pass.
indicating the row and column size of the input in the forward pass.
:param input_shape: The shape of the input parameter.
:param input_shape: The shape of the input parameter.
Not Optional, since given the input_shape and the subsample values,
multiple input_shape may be plausible.
:type filter_shape: None, tuple/list of len 4 of int or Constant variable
:param filter_shape: The shape of the filters parameter.
Optional, possibly used to choose an optimal implementation.
Optional, possibly used to choose an optimal implementation.
You can give ``None`` for any element of the list to specify that this
You can give ``None`` for any element of the list to specify that this
element is not known at compile time.
element is not known at compile time.
:type filter_shape: None, tuple/list of len 4 of int or Constant variable
:param filter_shape: The shape of the filters parameter.
Not Optional, since given the output_grad_shape and the input_shape,
multiple filter_shape may be plausible.
:type border_mode: str, int or tuple of two int
:type border_mode: str, int or tuple of two int
:param border_mode: Either of the following:
:param border_mode: Either of the following:
* ``'valid'``: apply filter wherever it completely overlaps with the
* ``'valid'``: apply filter wherever it completely overlaps with the
...
@@ -350,12 +356,12 @@ def gradWeights(input,
...
@@ -350,12 +356,12 @@ def gradWeights(input,
"""
"""
gradWeight_op
=
AbstractConv2d_gradWeights
(
imshp
=
input_shape
,
gradWeight_op
=
AbstractConv2d_gradWeights
(
imshp
=
input_shape
,
kshp
=
filter_shape
,
kshp
=
filter_shape
,
border_mode
=
border_mode
,
border_mode
=
border_mode
,
subsample
=
subsample
,
subsample
=
subsample
,
filter_flip
=
filter_flip
)
filter_flip
=
filter_flip
)
return
gradWeight_op
(
input
,
output
,
input_shape
)
return
gradWeight_op
(
input
,
output
_grad
,
input_shape
)
class
BaseAbstractConv2d
(
Op
):
class
BaseAbstractConv2d
(
Op
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论