paddlespeech.t2s.modules.tacotron2.decoder 模块
Tacotron2 解码器相关模块。
- class paddlespeech.t2s.modules.tacotron2.decoder.Decoder(idim, odim, att, dlayers=2, dunits=1024, prenet_layers=2, prenet_units=256, postnet_layers=5, postnet_chans=512, postnet_filts=5, output_activation_fn=None, cumulate_att_w=True, use_batch_norm=True, use_concate=True, dropout_rate=0.5, zoneout_rate=0.1, reduction_factor=1)[来源]
基础:
Layer声谱图预测网络的解码器模块。 这是Tacotron2中声谱图预测网络的解码器模块,描述在 `Natural TTS Synthesis by Conditioning WaveNet on Mel Spectrogram Predictions`_ 中。解码器从隐藏状态的序列生成特征的序列。 .. Natural TTS Synthesis by Conditioning WaveNet on Mel Spectrogram Predictions:
方法
__call__(*inputs, **kwargs)将self作为一个函数调用。
add_parameter(name, parameter)添加一个参数实例。
add_sublayer(name, sublayer)添加一个子层实例。
apply(fn)递归地将
fn应用到每个子层(由.sublayers()返回)以及自身。buffers([include_sublayers])返回当前层及其子层中的所有缓冲区的列表。
calculate_all_attentions(hs, hlens, ys)计算所有的注意力权重。
children()返回一个迭代器,遍历直接子层。
clear_gradients()清除此层所有参数的梯度。
create_parameter(shape[, attr, dtype, ...])为该层创建参数。
create_tensor([name, persistable, dtype])为该层创建张量。
create_variable([name, persistable, dtype])为该层创建张量。
eval()将该层及其所有子层设置为评估模式。
extra_repr()该层的额外表示,您可以自定义实现自己的层。
forward(hs, hlens, ys)计算前向传播。
full_name()此层的完整名称,由 name_scope + "/" + MyLayer.__class__.__name__ 组成
inference(h[, threshold, minlenratio, ...])根据字符序列生成特征序列。
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()将此层及其所有子层设置为训练模式。
向后
注册状态字典钩子
- calculate_all_attentions(hs, hlens, ys)[来源]
计算所有的注意力权重。
- Args:
- hs (Tensor):
填充隐藏状态序列的批次(B,Tmax,idim)。
- hlens (Tensor(int64)):
每个输入批次的长度批次 (B,)。
- ys (Tensor):
填充目标特征的序列批次 (B, Lmax, odim)。
- Returns:
- numpy.ndarray:
注意力权重的批次 (B, Lmax, Tmax)。
- Note:
该计算是以教师强制的方式进行的。
- forward(hs, hlens, ys)[来源]
计算前向传播。
- Args:
- hs (Tensor):
填充隐状态序列的批次(B,Tmax,idim)。
- hlens (Tensor(int64) padded):
每个输入批次的长度批次 (B,)。
- ys (Tensor):
批量填充目标特征序列 (B, Lmax, odim)。
- Returns:
- Tensor:
后处理网络的输出张量批次 (B, Lmax, odim)。
- Tensor:
后处理网络之前的输出张量批次 (B, Lmax, odim)。
- Tensor:
停止预测的logits批次(B,Lmax)。
- Tensor:
注意力权重的批次 (B, Lmax, Tmax)。
- Note:
此计算以教师引导的方式进行。
- inference(h, threshold=0.5, minlenratio=0.0, maxlenratio=10.0, use_att_constraint=False, backward_window=None, forward_window=None)[来源]
- Generate the sequence of features given the sequences of characters.
- Args:
- h(Tensor):
编码器隐状态的输入序列 (T, C)。
- threshold(float, optional, optional):
停止生成的阈值。 (默认值 = 0.5)
- minlenratio(float, optional, optional):
最小长度比例。如果设置为 1.0 并且输入长度为 10,输出的最小长度将为 10 * 1 = 10。 (默认值 = 0.0)
- maxlenratio(float, optional, optional):
最小长度比例。如果设置为10且输入长度为10,
输出的最大长度为 10 * 10 = 100。 (默认值 = 0.0)
- use_att_constraint(bool, optional):
是否应用在 Deep Voice 3 中引入的注意力约束。 (默认值 = False)
- backward_window(int, optional):
在注意力约束中的向后窗口大小。 (默认值 = None)
- forward_window(int, optional):
(默认值 = None)
- Returns:
- Tensor:
特征的输出序列 (L, odim)。
- Tensor:
停止概率的输出序列 (L,).
- Tensor:
注意力权重 (L, T).
- Note:
此计算以自回归方式进行。
- class paddlespeech.t2s.modules.tacotron2.decoder.Postnet(idim, odim, n_layers=5, n_chans=512, n_filts=5, dropout_rate=0.5, use_batch_norm=True)[来源]
基础:
Layer用于频谱图预测网络的Postnet模块。
这是Spectrogram预测网络中Postnet的一个模块, 在`Natural TTS Synthesis by Conditioning WaveNet on Mel Spectrogram Predictions`_中描述。 Postnet预测细化了解码器的预测 Mel-filterbank,这有助于补偿声谱图的细节结构。
方法
__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)计算前向传播。
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()将此层及其所有子层设置为训练模式。
向后
注册状态字典钩子
- class paddlespeech.t2s.modules.tacotron2.decoder.Prenet(idim, n_layers=2, n_units=256, dropout_rate=0.5)[来源]
基础:
Layer用于光谱图预测网络解码器的Prenet模块。
这是在声谱图预测网络解码器中Prenet的一个模块,在`Natural TTS Synthesis by Conditioning WaveNet on Mel Spectrogram Predictions`_中描述。Prenet对输入进行非线性转换,然后输入自回归LSTM,这有助于学习对角注意力。
备注
该模块在评估时始终应用dropout。查看详细信息在 `Natural TTS Synthesis by Conditioning WaveNet on Mel Spectrogram Predictions`_。
方法
__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)计算正向传播。
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()将此层及其所有子层设置为训练模式。
向后
注册状态字典钩子
- class paddlespeech.t2s.modules.tacotron2.decoder.ZoneOutCell(cell, zoneout_rate=0.1)[来源]
基础:
LayerZoneOut单元模块。 这是一个关于zoneout的模块,描述在 Zoneout: Regularizing RNNs by Randomly Preserving Hidden Activations。 这个代码是从 eladhoffer/seq2seq.pytorch 修改而来的。 示例 -----------
>>> lstm = paddle.nn.LSTMCell(16, 32) >>> lstm = ZoneOutCell(lstm, 0.5)
方法
__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(inputs, hidden)计算前向传播。
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()将此层及其所有子层设置为训练模式。
向后
注册状态字典钩子