paddlespeech.s2t.modules.subsampling 模块

子采样层定义。

class paddlespeech.s2t.modules.subsampling.Conv2dSubsampling4(idim: int, odim: int, dropout_rate: float, pos_enc_class: ~paddle.fluid.dygraph.layers.Layer = <class 'paddlespeech.s2t.modules.embedding.PositionalEncoding'>)[来源]

基础: Conv2dSubsampling

卷积二维下采样(至1/4长度)。

方法

__call__(*inputs, **kwargs)

将self作为一个函数调用。

add_parameter(name, parameter)

添加一个参数实例。

add_sublayer(name, sublayer)

添加一个子层实例。

apply(fn)

递归地将 fn 应用到每个子层(由 .sublayers() 返回)以及自身。

buffers([include_sublayers])

返回当前层及其子层中的所有缓冲区的列表。

children()

返回一个迭代器,遍历直接子层。

clear_gradients()

清除此层所有参数的梯度。

create_parameter(shape[, attr, dtype, ...])

为该层创建参数。

create_tensor([name, persistable, dtype])

为该层创建张量。

create_variable([name, persistable, dtype])

为该层创建张量。

eval()

将该层及其所有子层设置为评估模式。

extra_repr()

该层的额外表示,您可以自定义实现自己的层。

forward(x, x_mask[, offset])

对x进行下采样。 参数: x (paddle.Tensor):输入张量 (#batch, time, idim)。 x_mask (paddle.Tensor):输入掩码 (#batch, 1, time)。 offset (int):位置编码偏移。 返回: paddle.Tensor:下采样张量 (#batch, time', odim), 其中 time' = time // 4。 paddle.Tensor:位置编码 paddle.Tensor:下采样掩码 (#batch, 1, time'), 其中 time' = time // 4。

full_name()

此层的完整名称,由 name_scope + "/" + MyLayer.__class__.__name__ 组成

load_dict(state_dict[, use_structured_name])

从 state_dict 设置参数和可持久化缓存。

named_buffers([prefix, include_sublayers])

返回一个迭代器,遍历层中的所有缓冲区,生成名称和张量的元组。

named_children()

返回一个直接子层的迭代器,同时提供层的名称和层本身。

named_parameters([prefix, include_sublayers])

返回一个迭代器,遍历层中的所有参数,生成名称和参数的元组。

named_sublayers([prefix, include_self, ...])

返回Layer中所有子层的迭代器,生成名称和子层的元组。

parameters([include_sublayers])

返回当前层及其子层的所有参数的列表。

register_buffer(name, tensor[, persistable])

将一个张量注册为该层的缓冲区。

register_forward_post_hook(hook)

为层注册一个前向后钩子。

register_forward_pre_hook(hook)

为层注册一个前向预钩子。

set_dict(state_dict[, use_structured_name])

从 state_dict 设置参数和可持久化的缓冲区。

set_state_dict(state_dict[, use_structured_name])

从state_dict设置参数和持久化缓冲区。

state_dict([destination, include_sublayers, ...])

获取当前层及其子层的所有参数和可持久化缓冲区。

sublayers([include_self])

返回子层的列表。

to([device, dtype, blocking])

通过给定的设备、数据类型和阻塞方式转换层的参数和缓冲区。

to_static_state_dict([destination, ...])

获取当前层及其子层的所有参数和缓冲区。

train()

将此层及其所有子层设置为训练模式。

向后

位置编码

注册状态字典钩子

forward(x: Tensor, x_mask: Tensor, offset: int = 0) Tuple[Tensor, Tensor, Tensor][来源]

子样本 x。 参数:

x (paddle.Tensor): 输入张量 (#batch, time, idim).
x_mask (paddle.Tensor): 输入掩码 (#batch, 1, time).
offset (int): 位置编码偏移量.

Returns:
paddle.Tensor: Subsampled tensor (#batch, time', odim),

在这里时间' = 时间 // 4.

paddle.Tensor: 位置编码 paddle.Tensor: 子采样掩码 (#batch, 1, time'),

其中时间' = 时间 // 4.

class paddlespeech.s2t.modules.subsampling.Conv2dSubsampling6(idim: int, odim: int, dropout_rate: float, pos_enc_class: ~paddle.fluid.dygraph.layers.Layer = <class 'paddlespeech.s2t.modules.embedding.PositionalEncoding'>)[来源]

基础: Conv2dSubsampling

卷积二维下采样(至 1/6 长度)。

方法

__call__(*inputs, **kwargs)

将self作为一个函数调用。

add_parameter(name, parameter)

添加一个参数实例。

add_sublayer(name, sublayer)

添加一个子层实例。

apply(fn)

递归地将 fn 应用到每个子层(由 .sublayers() 返回)以及自身。

buffers([include_sublayers])

返回当前层及其子层中的所有缓冲区的列表。

children()

返回一个迭代器,遍历直接子层。

clear_gradients()

清除此层所有参数的梯度。

create_parameter(shape[, attr, dtype, ...])

为该层创建参数。

create_tensor([name, persistable, dtype])

为该层创建张量。

create_variable([name, persistable, dtype])

为该层创建张量。

eval()

将该层及其所有子层设置为评估模式。

extra_repr()

该层的额外表示,您可以自定义实现自己的层。

forward(x, x_mask[, offset])

对 x 进行下采样。 参数: x (paddle.Tensor): 输入张量 (#batch, time, idim)。 x_mask (paddle.Tensor): 输入掩码 (#batch, 1, time)。 offset (int): 位置编码偏移。 返回: paddle.Tensor: 下采样的张量 (#batch, time', odim), 其中 time' = time // 6。 paddle.Tensor: 位置编码 paddle.Tensor: 下采样的掩码 (#batch, 1, time'), 其中 time' = time // 6。

full_name()

此层的完整名称,由 name_scope + "/" + MyLayer.__class__.__name__ 组成

load_dict(state_dict[, use_structured_name])

从 state_dict 设置参数和可持久化缓存。

named_buffers([prefix, include_sublayers])

返回一个迭代器,遍历层中的所有缓冲区,生成名称和张量的元组。

named_children()

返回一个直接子层的迭代器,同时提供层的名称和层本身。

named_parameters([prefix, include_sublayers])

返回一个迭代器,遍历层中的所有参数,生成名称和参数的元组。

named_sublayers([prefix, include_self, ...])

返回Layer中所有子层的迭代器,生成名称和子层的元组。

parameters([include_sublayers])

返回当前层及其子层的所有参数的列表。

register_buffer(name, tensor[, persistable])

将一个张量注册为该层的缓冲区。

register_forward_post_hook(hook)

为层注册一个前向后钩子。

register_forward_pre_hook(hook)

为层注册一个前向预钩子。

set_dict(state_dict[, use_structured_name])

从 state_dict 设置参数和可持久化的缓冲区。

set_state_dict(state_dict[, use_structured_name])

从state_dict设置参数和持久化缓冲区。

state_dict([destination, include_sublayers, ...])

获取当前层及其子层的所有参数和可持久化缓冲区。

sublayers([include_self])

返回子层的列表。

to([device, dtype, blocking])

通过给定的设备、数据类型和阻塞方式转换层的参数和缓冲区。

to_static_state_dict([destination, ...])

获取当前层及其子层的所有参数和缓冲区。

train()

将此层及其所有子层设置为训练模式。

向后

位置编码

注册状态字典钩子

forward(x: Tensor, x_mask: Tensor, offset: int = 0) Tuple[Tensor, Tensor, Tensor][来源]

子样本 x。 参数:

x (paddle.Tensor): 输入张量 (#batch, time, idim). x_mask (paddle.Tensor): 输入掩码 (#batch, 1, time). offset (int): 位置编码偏移量.

Returns:
paddle.Tensor: Subsampled tensor (#batch, time', odim),

其中时间' = 时间 // 6.

paddle.Tensor: 位置编码 paddle.Tensor: 子采样掩码 (#batch, 1, time'),

其中 time' = time // 6。

class paddlespeech.s2t.modules.subsampling.Conv2dSubsampling8(idim: int, odim: int, dropout_rate: float, pos_enc_class: ~paddle.fluid.dygraph.layers.Layer = <class 'paddlespeech.s2t.modules.embedding.PositionalEncoding'>)[来源]

基础: Conv2dSubsampling

二维卷积下采样(至1/8长度)。

方法

__call__(*inputs, **kwargs)

将self作为一个函数调用。

add_parameter(name, parameter)

添加一个参数实例。

add_sublayer(name, sublayer)

添加一个子层实例。

apply(fn)

递归地将 fn 应用到每个子层(由 .sublayers() 返回)以及自身。

buffers([include_sublayers])

返回当前层及其子层中的所有缓冲区的列表。

children()

返回一个迭代器,遍历直接子层。

clear_gradients()

清除此层所有参数的梯度。

create_parameter(shape[, attr, dtype, ...])

为该层创建参数。

create_tensor([name, persistable, dtype])

为该层创建张量。

create_variable([name, persistable, dtype])

为该层创建张量。

eval()

将该层及其所有子层设置为评估模式。

extra_repr()

该层的额外表示,您可以自定义实现自己的层。

forward(x, x_mask[, offset])

对 x 进行子采样。 参数: x (paddle.Tensor): 输入张量 (#batch, time, idim)。 x_mask (paddle.Tensor): 输入掩码 (#batch, 1, time)。 offset (int): 位置编码偏移。 返回: paddle.Tensor: 子采样张量 (#batch, time', odim), 其中 time' = time // 8。 paddle.Tensor: 位置编码 paddle.Tensor: 子采样掩码 (#batch, 1, time'), 其中 time' = time // 8。

full_name()

此层的完整名称,由 name_scope + "/" + MyLayer.__class__.__name__ 组成

load_dict(state_dict[, use_structured_name])

从 state_dict 设置参数和可持久化缓存。

named_buffers([prefix, include_sublayers])

返回一个迭代器,遍历层中的所有缓冲区,生成名称和张量的元组。

named_children()

返回一个直接子层的迭代器,同时提供层的名称和层本身。

named_parameters([prefix, include_sublayers])

返回一个迭代器,遍历层中的所有参数,生成名称和参数的元组。

named_sublayers([prefix, include_self, ...])

返回Layer中所有子层的迭代器,生成名称和子层的元组。

parameters([include_sublayers])

返回当前层及其子层的所有参数的列表。

register_buffer(name, tensor[, persistable])

将一个张量注册为该层的缓冲区。

register_forward_post_hook(hook)

为层注册一个前向后钩子。

register_forward_pre_hook(hook)

为层注册一个前向预钩子。

set_dict(state_dict[, use_structured_name])

从 state_dict 设置参数和可持久化的缓冲区。

set_state_dict(state_dict[, use_structured_name])

从state_dict设置参数和持久化缓冲区。

state_dict([destination, include_sublayers, ...])

获取当前层及其子层的所有参数和可持久化缓冲区。

sublayers([include_self])

返回子层的列表。

to([device, dtype, blocking])

通过给定的设备、数据类型和阻塞方式转换层的参数和缓冲区。

to_static_state_dict([destination, ...])

获取当前层及其子层的所有参数和缓冲区。

train()

将此层及其所有子层设置为训练模式。

向后

位置编码

注册状态字典钩子

forward(x: Tensor, x_mask: Tensor, offset: int = 0) Tuple[Tensor, Tensor, Tensor][来源]

子样本 x。 参数:

x (paddle.Tensor): 输入张量 (#batch, time, idim). x_mask (paddle.Tensor): 输入掩码 (#batch, 1, time). offset (int): 位置编码偏移量.

Returns:
paddle.Tensor: Subsampled tensor (#batch, time', odim),

其中时间' = 时间 // 8.

paddle.Tensor: 位置编码 paddle.Tensor: 子采样掩码 (#batch, 1, time'),

其中 time' = time // 8。

class paddlespeech.s2t.modules.subsampling.DepthwiseConv2DSubsampling4(idim: int, odim: int, pos_enc_class: Layer, dw_stride: bool = False, input_size: int = 80, input_dropout_rate: float = 0.1, init_weights: bool = True)[来源]

基础: BaseSubsampling

深度可分离卷积 2D 下采样(到 1/4 长度)。

Args:

idim (int): 输入维度。
odim (int): 输出维度。
pos_enc_class (nn.Layer): 位置编码类。
dw_stride (int): 是否进行深度卷积。
input_size (int): 滤波器组维度。

方法

__call__(*inputs, **kwargs)

将self作为一个函数调用。

add_parameter(name, parameter)

添加一个参数实例。

add_sublayer(name, sublayer)

添加一个子层实例。

apply(fn)

递归地将 fn 应用到每个子层(由 .sublayers() 返回)以及自身。

buffers([include_sublayers])

返回当前层及其子层中的所有缓冲区的列表。

children()

返回一个迭代器,遍历直接子层。

clear_gradients()

清除此层所有参数的梯度。

create_parameter(shape[, attr, dtype, ...])

为该层创建参数。

create_tensor([name, persistable, dtype])

为该层创建张量。

create_variable([name, persistable, dtype])

为该层创建张量。

eval()

将该层及其所有子层设置为评估模式。

extra_repr()

该层的额外表示,您可以自定义实现自己的层。

forward(x, x_mask[, offset])

定义每次调用时执行的计算。

full_name()

此层的完整名称,由 name_scope + "/" + MyLayer.__class__.__name__ 组成

load_dict(state_dict[, use_structured_name])

从 state_dict 设置参数和可持久化缓存。

named_buffers([prefix, include_sublayers])

返回一个迭代器,遍历层中的所有缓冲区,生成名称和张量的元组。

named_children()

返回一个直接子层的迭代器,同时提供层的名称和层本身。

named_parameters([prefix, include_sublayers])

返回一个迭代器,遍历层中的所有参数,生成名称和参数的元组。

named_sublayers([prefix, include_self, ...])

返回Layer中所有子层的迭代器,生成名称和子层的元组。

parameters([include_sublayers])

返回当前层及其子层的所有参数的列表。

register_buffer(name, tensor[, persistable])

将一个张量注册为该层的缓冲区。

register_forward_post_hook(hook)

为层注册一个前向后钩子。

register_forward_pre_hook(hook)

为层注册一个前向预钩子。

set_dict(state_dict[, use_structured_name])

从 state_dict 设置参数和可持久化的缓冲区。

set_state_dict(state_dict[, use_structured_name])

从state_dict设置参数和持久化缓冲区。

state_dict([destination, include_sublayers, ...])

获取当前层及其子层的所有参数和可持久化缓冲区。

sublayers([include_self])

返回子层的列表。

to([device, dtype, blocking])

通过给定的设备、数据类型和阻塞方式转换层的参数和缓冲区。

to_static_state_dict([destination, ...])

获取当前层及其子层的所有参数和缓冲区。

train()

将此层及其所有子层设置为训练模式。

向后

位置编码

注册状态字典钩子

forward(x: Tensor, x_mask: Tensor, offset: int = 0) Tuple[Tensor, Tensor, Tensor][来源]

定义每次调用时执行的计算。应该被所有子类重写。

Parameters:

*inputs(tuple): 解包的元组参数 **kwargs(dict): 解包的字典参数

class paddlespeech.s2t.modules.subsampling.LinearNoSubsampling(idim: int, odim: int, dropout_rate: float, pos_enc_class: ~paddle.fluid.dygraph.layers.Layer = <class 'paddlespeech.s2t.modules.embedding.PositionalEncoding'>)[来源]

基础: BaseSubsampling

线性变换输入而不进行下采样。

方法

__call__(*inputs, **kwargs)

将self作为一个函数调用。

add_parameter(name, parameter)

添加一个参数实例。

add_sublayer(name, sublayer)

添加一个子层实例。

apply(fn)

递归地将 fn 应用到每个子层(由 .sublayers() 返回)以及自身。

buffers([include_sublayers])

返回当前层及其子层中的所有缓冲区的列表。

children()

返回一个迭代器,遍历直接子层。

clear_gradients()

清除此层所有参数的梯度。

create_parameter(shape[, attr, dtype, ...])

为该层创建参数。

create_tensor([name, persistable, dtype])

为该层创建张量。

create_variable([name, persistable, dtype])

为该层创建张量。

eval()

将该层及其所有子层设置为评估模式。

extra_repr()

该层的额外表示,您可以自定义实现自己的层。

forward(x, x_mask[, offset])

输入 x。参数: x (paddle.Tensor): 输入张量 (#batch, time, idim)。 x_mask (paddle.Tensor): 输入掩码 (#batch, 1, time)。 offset (int): 位置编码偏移量。 返回: paddle.Tensor: 线性输入张量 (#batch, time', odim), 其中 time' = time 。 paddle.Tensor: 位置编码 paddle.Tensor: 线性输入掩码 (#batch, 1, time'), 其中 time' = time 。

full_name()

此层的完整名称,由 name_scope + "/" + MyLayer.__class__.__name__ 组成

load_dict(state_dict[, use_structured_name])

从 state_dict 设置参数和可持久化缓存。

named_buffers([prefix, include_sublayers])

返回一个迭代器,遍历层中的所有缓冲区,生成名称和张量的元组。

named_children()

返回一个直接子层的迭代器,同时提供层的名称和层本身。

named_parameters([prefix, include_sublayers])

返回一个迭代器,遍历层中的所有参数,生成名称和参数的元组。

named_sublayers([prefix, include_self, ...])

返回Layer中所有子层的迭代器,生成名称和子层的元组。

parameters([include_sublayers])

返回当前层及其子层的所有参数的列表。

register_buffer(name, tensor[, persistable])

将一个张量注册为该层的缓冲区。

register_forward_post_hook(hook)

为层注册一个前向后钩子。

register_forward_pre_hook(hook)

为层注册一个前向预钩子。

set_dict(state_dict[, use_structured_name])

从 state_dict 设置参数和可持久化的缓冲区。

set_state_dict(state_dict[, use_structured_name])

从state_dict设置参数和持久化缓冲区。

state_dict([destination, include_sublayers, ...])

获取当前层及其子层的所有参数和可持久化缓冲区。

sublayers([include_self])

返回子层的列表。

to([device, dtype, blocking])

通过给定的设备、数据类型和阻塞方式转换层的参数和缓冲区。

to_static_state_dict([destination, ...])

获取当前层及其子层的所有参数和缓冲区。

train()

将此层及其所有子层设置为训练模式。

向后

位置编码

注册状态字典钩子

forward(x: Tensor, x_mask: Tensor, offset: int = 0) Tuple[Tensor, Tensor, Tensor][来源]

输入 x。
参数:

x (paddle.Tensor): 输入张量 (#batch, time, idim). x_mask (paddle.Tensor): 输入掩码 (#batch, 1, time). offset (int): 位置编码偏移量.

Returns:
paddle.Tensor: linear input tensor (#batch, time', odim),

其中 time' = time 。

paddle.Tensor: 位置编码 paddle.Tensor: 线性输入掩码 (#batch, 1, time'),

其中时间' = 时间。