paddlespeech.t2s.modules.transformer.encoder 模块

class paddlespeech.t2s.modules.transformer.encoder.BaseEncoder(idim: int, attention_dim: int = 256, attention_heads: int = 4, linear_units: int = 2048, num_blocks: int = 6, dropout_rate: float = 0.1, positional_dropout_rate: float = 0.1, attention_dropout_rate: float = 0.0, input_layer: str = 'conv2d', normalize_before: bool = True, concat_after: bool = False, positionwise_layer_type: str = 'linear', positionwise_conv_kernel_size: int = 1, macaron_style: bool = False, pos_enc_layer_type: str = 'abs_pos', selfattention_layer_type: str = 'selfattn', activation_type: str = 'swish', use_cnn_module: bool = False, zero_triu: bool = False, cnn_module_kernel: int = 31, padding_idx: int = -1, stochastic_depth_rate: float = 0.0, intermediate_layers: Optional[List[int]] = None, encoder_type: str = 'transformer')[来源]

基础: Layer

基本编码器模块。

Args:
idim (int):

输入维度。

attention_dim (int):

注意力的维度。

attention_heads (int):

多头注意力的头数量。

linear_units (int):

位置逐步前馈的单元数量。

num_blocks (int):

解码器块的数量。

dropout_rate (float):

dropout 率。

positional_dropout_rate (float):

添加位置编码后的 dropout 率。

attention_dropout_rate (float):

注意力中的丢弃率。

input_layer (Union[str, nn.Layer]):

输入层类型。

normalize_before (bool):

是否在第一个模块之前使用层归一化。

concat_after (bool):

是否连接注意力层的输入和输出。 如果为真,将应用额外的线性变换。 即 x -> x + linear(concat(x, att(x))) 如果为假,则不应用额外的线性变换。即 x -> x + att(x)

positionwise_layer_type (str):

"线性", "一维卷积", 或 "一维卷积-线性".

positionwise_conv_kernel_size (int):

位置逐层卷积1d层的核大小。

macaron_style (bool):

是否对逐位置层使用马卡龙风格。

pos_enc_layer_type (str):

编码器位置编码层类型。

selfattention_layer_type (str):

编码器注意力层类型。

activation_type (str):

编码器激活函数类型。

use_cnn_module (bool):

是否使用卷积模块。

zero_triu (bool):

是否将注意力矩阵的上三角部分置为零。

cnn_module_kernel (int):

卷积模块的卷积核大小。

padding_idx (int):

输入层=embed的填充索引。

stochastic_depth_rate (float):

跳过编码器层的最大概率。

intermediate_layers (Union[List[int], None]):

中间CTC层的索引。
索引从1开始。
如果不为None,将返回中间输出(这会改变返回类型签名。)

encoder_type (str): "transformer" 或 "conformer"。

方法

__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(xs, masks)

对输入序列进行编码。

full_name()

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

get_positionwise_layer([...])

定义按位置分层。

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(xs, masks)[来源]

编码输入序列。

Args:
xs (Tensor):

输入张量 (#batch, time, idim).

masks (Tensor):

掩码张量 (#batch, 1, time).

Returns:
Tensor:

输出张量 (#batch, time, attention_dim)。

Tensor:

掩码张量 (#batch, 1, 时间).

get_embed(idim, input_layer='conv2d', attention_dim: int = 256, pos_enc_class=<class 'paddlespeech.t2s.modules.transformer.embedding.PositionalEncoding'>, dropout_rate: int = 0.1, positional_dropout_rate: int = 0.1, padding_idx: int = -1)[来源]
get_encoder_selfattn_layer(selfattention_layer_type: str = 'selfattn', attention_heads: int = 4, attention_dim: int = 256, attention_dropout_rate: float = 0.0, zero_triu: bool = False, pos_enc_layer_type: str = 'abs_pos')[来源]
get_pos_enc_class(pos_enc_layer_type: str = 'abs_pos', selfattention_layer_type: str = 'selfattn')[来源]
get_positionwise_layer(positionwise_layer_type: str = 'linear', attention_dim: int = 256, linear_units: int = 2048, dropout_rate: float = 0.1, positionwise_conv_kernel_size: int = 1, activation: Layer = ReLU())[来源]

定义逐位置层。

class paddlespeech.t2s.modules.transformer.encoder.CNNDecoder(emb_dim: int = 256, odim: int = 80, kernel_size: int = 5, dropout_rate: float = 0.2, resblock_kernel_sizes: List[int] = [256, 256])[来源]

基础: Layer

比原来的带有Prenet的解码器简单得多。

方法

__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(xs[, masks])

编码输入序列。 参数: xs (Tensor): 输入张量 (#batch, time, idim)。 masks (Tensor): 掩码张量 (#batch, 1, time)。 返回: Tensor: 输出张量 (#batch, time, odim)。

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(xs, masks=None)[来源]

编码输入序列。

参数:

xs (Tensor):

输入张量 (#batch, time, idim).

masks (Tensor):

掩码张量 (#batch, 1, 时间).

Returns:

张量:输出张量 (#batch, time, odim)。

class paddlespeech.t2s.modules.transformer.encoder.CNNPostnet(odim: int = 80, kernel_size: int = 5, dropout_rate: float = 0.2, resblock_kernel_sizes: List[int] = [256, 256])[来源]

基础: Layer

方法

__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(xs[, masks])

编码输入序列。 参数: xs (Tensor): 输入张量 (#batch, odim, time)。 masks (Tensor): 掩码张量 (#batch, 1, time)。 返回: Tensor: 输出张量 (#batch, odim, 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(xs, masks=None)[来源]

编码输入序列。

参数:

xs (Tensor):

输入张量 (#batch, odim, time)。

masks (Tensor):

掩码张量 (#batch, 1, 时间).

Returns:

张量:输出张量 (#batch, odim, time)。

class paddlespeech.t2s.modules.transformer.encoder.ConformerEncoder(idim: int, attention_dim: int = 256, attention_heads: int = 4, linear_units: int = 2048, num_blocks: int = 6, dropout_rate: float = 0.1, positional_dropout_rate: float = 0.1, attention_dropout_rate: float = 0.0, input_layer: str = 'conv2d', normalize_before: bool = True, concat_after: bool = False, positionwise_layer_type: str = 'linear', positionwise_conv_kernel_size: int = 1, macaron_style: bool = False, pos_enc_layer_type: str = 'rel_pos', selfattention_layer_type: str = 'rel_selfattn', activation_type: str = 'swish', use_cnn_module: bool = False, zero_triu: bool = False, cnn_module_kernel: int = 31, padding_idx: int = -1, stochastic_depth_rate: float = 0.0, intermediate_layers: Optional[List[int]] = None)[来源]

基类: BaseEncoder

Conformer 编码器模块。

Args:
idim (int):

输入维度。

attention_dim (int):

注意力的维度。

attention_heads (int):

多头注意力的头数量。

linear_units (int):

位置逐步前馈的单元数量。

num_blocks (int):

解码器块的数量。

dropout_rate (float):

dropout 率。

positional_dropout_rate (float):

添加位置编码后的 dropout 率。

attention_dropout_rate (float):

注意力中的丢弃率。

input_layer (Union[str, nn.Layer]):

输入层类型。

normalize_before (bool):

是否在第一个模块之前使用层归一化。

concat_after (bool):

是否连接注意力层的输入和输出。 如果为真,将应用额外的线性变换。 即 x -> x + linear(concat(x, att(x))) 如果为假,则不应用额外的线性变换。即 x -> x + att(x)

positionwise_layer_type (str):

"线性", "一维卷积", 或 "一维卷积-线性".

positionwise_conv_kernel_size (int):

位置逐层卷积1d层的核大小。

macaron_style (bool):

是否对逐位置层使用马卡龙风格。

pos_enc_layer_type (str):

编码器位置编码层类型。

selfattention_layer_type (str):

编码器注意力层类型。

activation_type (str):

编码器激活函数类型。

use_cnn_module (bool):

是否使用卷积模块。

zero_triu (bool):

是否将注意力矩阵的上三角部分置为零。

cnn_module_kernel (int):

卷积模块的卷积核大小。

padding_idx (int):

输入层=embed的填充索引。

stochastic_depth_rate (float):

跳过编码器层的最大概率。

intermediate_layers (Union[List[int], None]):

中间CTC层的索引。索引从1开始。 如果不为None,则返回中间输出(这会改变返回类型签名。)

方法

__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(xs, masks)

对输入序列进行编码。

full_name()

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

get_positionwise_layer([...])

定义位置层。

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(xs, masks)[来源]

编码输入序列。

Args:
xs (Tensor):

输入张量 (#batch, time, idim).

masks (Tensor):

掩码张量 (#batch, 1, 时间).

Returns:
Tensor:

输出张量 (#batch, time, attention_dim)。

Tensor:

掩码张量 (#batch, 1, 时间).

class paddlespeech.t2s.modules.transformer.encoder.Conv1dResidualBlock(idim: int = 256, odim: int = 256, kernel_size: int = 5, dropout_rate: float = 0.2)[来源]

基础: Layer

Encoder 类的简化版本的特殊模块。

方法

__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(xs)

编码输入序列。参数: xs (Tensor): 输入张量 (#batch, idim, T)。返回: Tensor: 输出张量 (#batch, odim, T)。

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(xs)[来源]

编码输入序列。 参数:

xs (Tensor):

输入张量 (#batch, idim, T)。

Returns:

张量:输出张量 (#batch, odim, T)。

class paddlespeech.t2s.modules.transformer.encoder.TransformerEncoder(idim, attention_dim: int = 256, attention_heads: int = 4, linear_units: int = 2048, num_blocks: int = 6, dropout_rate: float = 0.1, positional_dropout_rate: float = 0.1, attention_dropout_rate: float = 0.0, input_layer: str = 'conv2d', pos_enc_layer_type: str = 'abs_pos', normalize_before: bool = True, concat_after: bool = False, positionwise_layer_type: str = 'linear', positionwise_conv_kernel_size: int = 1, selfattention_layer_type: str = 'selfattn', activation_type: str = 'relu', padding_idx: int = -1)[来源]

基类: BaseEncoder

转换器编码模块。

Args:
idim (int):

输入维度。

attention_dim (int):

注意力的维度。

attention_heads (int):

多头注意力的头数量。

linear_units (int):

位置逐步前馈的单元数量。

num_blocks (int):

解码器块的数量。

dropout_rate (float):

dropout 率。

positional_dropout_rate (float):

添加位置编码后的 dropout 率。

attention_dropout_rate (float):

注意力中的丢弃率。

input_layer (Union[str, paddle.nn.Layer]):

输入层类型。

pos_enc_layer_type (str):

编码器位置编码层类型。

normalize_before (bool):

是否在第一个模块之前使用层归一化。

concat_after (bool):

是否连接注意力层的输入和输出。 如果为真,将应用额外的线性变换。 即 x -> x + linear(concat(x, att(x))) 如果为假,则不应用额外的线性变换。即 x -> x + att(x)

positionwise_layer_type (str):

"线性", "一维卷积", 或 "一维卷积-线性".

positionwise_conv_kernel_size (int):

位置逐层卷积1d层的核大小。

selfattention_layer_type (str):

编码器注意力层类型。

activation_type (str):

编码器激活函数类型。

padding_idx (int):

输入层=embed的填充索引。

方法

__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(xs, masks[, note_emb, note_dur_emb, ...])

编码器输入序列。

forward_one_step(xs, masks[, cache])

编码输入帧。

full_name()

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

get_positionwise_layer([...])

定义位置层。

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(xs: Tensor, masks: Tensor, note_emb: Optional[Tensor] = None, note_dur_emb: Optional[Tensor] = None, is_slur_emb: Optional[Tensor] = None, scale: int = 16)[来源]

编码器输入序列。

Args:
xs(Tensor):

输入张量 (#batch, time, idim).

masks(Tensor):

掩码张量 (#batch, 1, 时间).

note_emb(Tensor):

输入张量 (#batch, time, attention_dim)。

note_dur_emb(Tensor):

输入张量 (#batch, time, attention_dim)。

is_slur_emb(Tensor):

输入张量 (#batch, time, attention_dim)。

Returns:
Tensor:

输出张量 (#batch, time, attention_dim)。

Tensor:

掩码张量 (#batch, 1, 时间).

forward_one_step(xs, masks, cache=None)[来源]

编码输入帧。

Args:
xs (Tensor):

输入张量。

masks (Tensor):

掩码张量。

cache (List[Tensor]):

缓存张量列表。

Returns:
Tensor:

输出张量。

Tensor:

掩码张量。

List[Tensor]:

新缓存张量列表。