Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
9e6007f0
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
9e6007f0
编写于
12月 29, 2022
作者:
W
wangzhen38
提交者:
GitHub
12月 29, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[fluid remove] rawconv (#49395)
* [fluid remove] rawconv
上级
ffa32e44
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
0 addition
and
79 deletion
+0
-79
python/paddle/fluid/dygraph/nn.py
python/paddle/fluid/dygraph/nn.py
+0
-79
未找到文件。
python/paddle/fluid/dygraph/nn.py
浏览文件 @
9e6007f0
...
...
@@ -320,82 +320,3 @@ class BatchNorm(layers.Layer):
# Currently, we don't support inplace in dygraph mode
return
self
.
_helper
.
append_activation
(
batch_norm_out
,
self
.
_act
)
class
RowConv
(
layers
.
Layer
):
"""
***Row-convolution operator***
The row convolution is called lookahead convolution. This operator was introduced in the following paper for DeepSpeech2:
http://www.cs.cmu.edu/~dyogatam/papers/wang+etal.iclrworkshop2016.pdf
The main motivation is that a bidirectional RNN, useful in DeepSpeech like speech models, learns representation for a sequence by performing a
forward and a backward pass through the entire sequence. However, unlike
unidirectional RNNs, bidirectional RNNs are challenging to deploy in an online
and low-latency setting. The lookahead convolution incorporates information
from future subsequences in a computationally efficient manner to improve
unidirectional recurrent neural networks. The row convolution operator is
different from the 1D sequence convolution, and is computed as follows:
Given an input sequence X of length t and input dimension D, and a filter (W) of size context * D.
More details about row_conv please refer to the design document https://github.com/PaddlePaddle/Paddle/issues/2228#issuecomment-303903645 .
Parameters:
name_scope(str): The name of this class.
future_context_size (int): Future context size. Please note, the shape
of convolution kernel is [future_context_size + 1, D].
param_attr (ParamAttr): Attributes of parameters, including
name, initializer etc. Default: None.
act (str): Non-linear activation to be applied to output variable. Default: None.
Attributes:
weight (Parameter): the learnable weights of this layer.
Returns:
the output(Out) is a LodTensor, which supports variable time-length input sequences.
The underlying tensor in this LodTensor is a matrix with shape T x N, i.e., the same shape as X.
Examples:
.. code-block:: python
import paddle.fluid as fluid
import numpy
with fluid.dygraph.guard():
x = numpy.random.random((16)).astype('float32')
rowConv = fluid.dygraph.nn.RowConv(
'RowConv', future_context_size=2)
ret = rowConv(fluid.dygraph.base.to_variable(x))
"""
def
__init__
(
self
,
name_scope
,
future_context_size
,
param_attr
=
None
,
act
=
None
):
assert
(
not
in_dygraph_mode
()
),
"RowConv is not supported by dynamic graph mode yet!"
super
().
__init__
(
name_scope
)
self
.
_act
=
act
self
.
_param_attr
=
param_attr
self
.
_future_context_size
=
future_context_size
def
_build_once
(
self
,
input
):
self
.
_dtype
=
self
.
_helper
.
input_dtype
(
input
)
filter_shape
=
[
self
.
_future_context_size
+
1
,
input
.
shape
[
1
]]
self
.
weight
=
self
.
create_parameter
(
attr
=
self
.
_param_attr
,
shape
=
filter_shape
,
dtype
=
self
.
_dtype
,
is_bias
=
False
,
)
def
forward
(
self
,
input
):
out
=
self
.
_helper
.
create_variable_for_type_inference
(
self
.
_dtype
)
self
.
_helper
.
append_op
(
type
=
'row_conv'
,
inputs
=
{
'X'
:
[
input
],
'Filter'
:
[
self
.
weight
]},
outputs
=
{
'Out'
:
[
out
]},
)
return
self
.
_helper
.
append_activation
(
out
,
act
=
self
.
_act
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录