paddlespeech.s2t.modules.encoder 模块
编码器定义。
- class paddlespeech.s2t.modules.encoder.BaseEncoder(input_size: int, output_size: 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, static_chunk_size: int = 0, use_dynamic_chunk: bool = False, global_cmvn: Optional[Layer] = None, use_dynamic_left_chunk: bool = False, max_len: int = 5000)[来源]
基础:
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, xs_lens[, decoding_chunk_size, ...])在张量中嵌入位置。参数: xs: 填充的输入张量 (B, L, D) xs_lens: 输入长度 (B) decoding_chunk_size: 用于动态块的解码块大小 0: 默认用于训练,使用随机动态块。 <0: 用于解码,使用完整块。 >0: 用于解码,使用设置的固定块大小。 num_decoding_left_chunks: 剩余块的数量,这用于解码, 块大小是 decoding_chunk_size。 >=0: 使用 num_decoding_left_chunks <0: 使用所有剩余块 返回: 编码器输出张量、长度和掩码。
forward_chunk(xs, offset, required_cache_size)前向仅一个块 参数: xs (paddle.Tensor):块音频特征输入,[B=1, T, D],其中 T==(chunk_size-1)*subsampling_rate + subsample.right_context + 1 offset (int):当前偏移在编码器输出时间戳 required_cache_size (int):下一个块所需的缓存大小 >=0:实际缓存大小 <0:表示需要所有历史缓存 att_cache(paddle.Tensor):用于 transformer/conformer 注意力的键和值的缓存张量。形状为 (elayers, head, cache_t1, d_k * 2),其中`head * d_k == hidden-dim` 和 cache_t1 == chunk_size * num_decoding_left_chunks。 cnn_cache (paddle.Tensor):conformer 中 cnn_module 的缓存张量, (elayers, B=1, hidden-dim, cache_t2),其中 cache_t2 == cnn.lorder - 1 返回: paddle.Tensor:当前输入 xs 的输出,(B=1, chunk_size, hidden-dim) paddle.Tensor:下一个块所需的新注意缓存,动态形状 (elayers, head, T, d_k*2),取决于所需缓存大小 paddle.Tensor:下一个块所需的新 conformer cnn 缓存, 形状与原始 cnn_cache 相同。
forward_chunk_by_chunk(xs, decoding_chunk_size)逐块前向输入,块大小类似于流式处理
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: Tensor, xs_lens: Tensor, decoding_chunk_size: int = 0, num_decoding_left_chunks: int = -1) Tuple[Tensor, Tensor][来源]
嵌入张量中的位置。
参数:xs: 填充输入张量 (B, L, D)
xs_lens: 输入长度 (B)
decoding_chunk_size: 动态块的解码块大小0: 训练的默认值,使用随机动态块。 <0: 解码时,使用完整块。 >0: 解码时,使用设定的固定块大小。
- num_decoding_left_chunks: number of left chunks, this is for decoding,
块大小是 decoding_chunk_size。 >=0:使用 num_decoding_left_chunks <0:使用所有剩余块
- Returns:
编码器输出张量、长度和掩码
- forward_chunk(xs: ~paddle.Tensor, offset: int, required_cache_size: int, att_cache: ~paddle.Tensor = Tensor(shape=[0, 0, 0, 0], dtype=float32, place=Place(cpu), stop_gradient=True, []), cnn_cache: ~paddle.Tensor = Tensor(shape=[0, 0, 0, 0], dtype=float32, place=Place(cpu), stop_gradient=True, []), att_mask: ~paddle.Tensor = Tensor(shape=[0, 0, 0], dtype=bool, place=Place(cpu), stop_gradient=True, [])) Tuple[Tensor, Tensor, Tensor][来源]
仅前进一个块 参数:
- xs (paddle.Tensor): chunk audio feat input, [B=1, T, D], where
T==(chunk_size-1)*subsampling_rate + subsample.right_context + 1
offset (int): 编码器输出时间戳的当前偏移量
required_cache_size (int): 下一个块所需的缓存大小计算 >=0: 实际缓存大小 <0: 意味着需要所有历史缓存
- att_cache(paddle.Tensor): cache tensor for key & val in
变换器/可变形注意力。形状为 (elayers, head, cache_t1, d_k * 2),其中`head * d_k == hidden-dim` 以及 cache_t1 == chunk_size * num_decoding_left_chunks。
- cnn_cache (paddle.Tensor): cache tensor for cnn_module in conformer,
(elayers, B=1, hidden-dim, cache_t2),其中 cache_t2 == cnn.lorder - 1
- Returns:
paddle.Tensor:当前输入 xs 的输出,(B=1, chunk_size, hidden-dim) paddle.Tensor:下一个块所需的新注意力缓存,动态形状
(elayers, head, T, d_k*2) 取决于所需的缓存大小
- paddle.Tensor: new conformer cnn cache required for next chunk, with
与原始 cnn_cache 形状相同
- forward_chunk_by_chunk(xs: Tensor, decoding_chunk_size: int, num_decoding_left_chunks: int = -1) Tuple[Tensor, Tensor][来源]
- Forward input chunk by chunk with chunk_size like a streaming
时尚
在这里,我们应该特别注意以流式方式逐块进行的计算缓存。当前网络的计算应考虑三件事:
变换器/符合器编码器层输出缓存
变换器中的卷积
子采样中的卷积
- However, we don't implement subsampling cache for:
我们可以通过重叠输入而不是缓存左侧上下文来控制子采样模块输出正确的结果,尽管这会浪费一些计算,但子采样在整个模型中的计算只占很小的一部分。
通常,在子采样模块中有几个具有下采样的卷积层,不同下采样率的不同卷积层进行缓存是棘手和复杂的。
目前,nn.Sequential用于堆叠子采样中的所有卷积层,我们需要重写它以使其与缓存一起工作,这并不被推荐。
- Args:
xs (paddle.Tensor): (1, max_len, dim)
chunk_size (int): 解码块大小。
num_left_chunks (int): 使用剩余块进行解码。
- class paddlespeech.s2t.modules.encoder.ConformerEncoder(input_size: int, output_size: 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 = 'rel_pos', normalize_before: bool = True, concat_after: bool = False, static_chunk_size: int = 0, use_dynamic_chunk: bool = False, global_cmvn: Optional[Layer] = None, use_dynamic_left_chunk: bool = False, positionwise_conv_kernel_size: int = 1, macaron_style: bool = True, selfattention_layer_type: str = 'rel_selfattn', activation_type: str = 'swish', use_cnn_module: bool = True, cnn_module_kernel: int = 15, causal: bool = False, cnn_module_norm: str = 'batch_norm', max_len: int = 5000)[来源]
基类:
BaseEncoderConformer 编码器模块。
方法
__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_lens[, decoding_chunk_size, ...])在张量中嵌入位置。参数: xs:填充输入张量 (B, L, D) xs_lens:输入长度 (B) decoding_chunk_size:动态块的解码块大小 0:训练的默认值,使用随机动态块。 <0: 解码时,使用完整块。 >0:解码时,使用设置的固定块大小。 num_decoding_left_chunks:剩余块的数量,这用于解码, 块大小为 decoding_chunk_size。 >=0:使用 num_decoding_left_chunks <0:使用所有剩余块 返回: 编码器输出张量,长度和掩码。
forward_chunk(xs, offset, required_cache_size)仅前向一个块 参数: xs (paddle.Tensor): 块音频特征输入, [B=1, T, D], 其中 T==(chunk_size-1)*subsampling_rate + subsample.right_context + 1 offset (int): 编码器输出时间戳中的当前偏移量 required_cache_size (int): 下一个块所需的缓存大小 >=0: 实际缓存大小 <0: 表示需要所有历史缓存 att_cache(paddle.Tensor): transformer/conformer 注意力中键和值的缓存张量。形状为 (elayers, head, cache_t1, d_k * 2), 其中`head * d_k == hidden-dim` 和 cache_t1 == chunk_size * num_decoding_left_chunks. cnn_cache (paddle.Tensor): conformer 中 cnn_module 的缓存张量, (elayers, B=1, hidden-dim, cache_t2), 其中 cache_t2 == cnn.lorder - 1 返回: paddle.Tensor: 当前输入 xs 的输出, (B=1, chunk_size, hidden-dim) paddle.Tensor: 下一个块所需的新注意力缓存, 动态形状 (elayers, head, T, d_k*2) 取决于 required_cache_size paddle.Tensor: 下一个块所需的新 conformer cnn 缓存,形状与原始 cnn_cache 相同。
forward_chunk_by_chunk(xs, decoding_chunk_size)逐块前向输入,像流媒体一样使用块大小
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.s2t.modules.encoder.SqueezeformerEncoder(input_size: int, encoder_dim: int = 256, output_size: int = 256, attention_heads: int = 4, num_blocks: int = 12, reduce_idx: Optional[Union[int, List[int]]] = 5, recover_idx: Optional[Union[int, List[int]]] = 11, feed_forward_expansion_factor: int = 4, dw_stride: bool = False, input_dropout_rate: float = 0.1, pos_enc_layer_type: str = 'rel_pos', time_reduction_layer_type: str = 'conv1d', feed_forward_dropout_rate: float = 0.1, attention_dropout_rate: float = 0.1, cnn_module_kernel: int = 31, cnn_norm_type: str = 'layer_norm', dropout: float = 0.1, causal: bool = False, adaptive_scale: bool = True, activation_type: str = 'swish', init_weights: bool = True, global_cmvn: Optional[Layer] = None, normalize_before: bool = False, use_dynamic_chunk: bool = False, concat_after: bool = False, static_chunk_size: int = 0, use_dynamic_left_chunk: bool = False)[来源]
基础:
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, xs_lens[, decoding_chunk_size, ...])在张量中嵌入位置。参数: xs: 填充的输入张量 (B, L, D) xs_lens: 输入长度 (B) decoding_chunk_size: 用于动态块的解码块大小 0: 默认用于训练,使用随机动态块。 <0: 用于解码,使用完整块。 >0: 用于解码,使用设置的固定块大小。 num_decoding_left_chunks: 剩余块的数量,这用于解码, 块大小是 decoding_chunk_size。 >=0: 使用 num_decoding_left_chunks <0: 使用所有剩余块 返回: 编码器输出张量、长度和掩码。
forward_chunk(xs, offset, required_cache_size)仅前进一个块
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()将此层及其所有子层设置为训练模式。
向后
calculate_downsampling_factor
检查递增列表
输出大小
注册状态字典钩子
- forward(xs: Tensor, xs_lens: Tensor, decoding_chunk_size: int = 0, num_decoding_left_chunks: int = -1) Tuple[Tensor, Tensor][来源]
嵌入张量中的位置。参数:
xs: 填充输入张量 (B, L, D) xs_lens: 输入长度 (B) decoding_chunk_size: 动态块的解码块大小
0: 训练的默认值,使用随机动态块。 <0: 解码时,使用完整块。 >0: 解码时,使用设定的固定块大小。
- num_decoding_left_chunks: number of left chunks, this is for decoding,
块大小是 decoding_chunk_size。 >=0:使用 num_decoding_left_chunks <0:使用所有剩余块
- Returns:
编码器输出张量、长度和掩码
- forward_chunk(xs: ~paddle.Tensor, offset: int, required_cache_size: int, att_cache: ~paddle.Tensor = Tensor(shape=[0, 0, 0, 0], dtype=float32, place=Place(cpu), stop_gradient=True, []), cnn_cache: ~paddle.Tensor = Tensor(shape=[0, 0, 0, 0], dtype=float32, place=Place(cpu), stop_gradient=True, []), att_mask: ~paddle.Tensor = Tensor(shape=[0, 0, 0], dtype=bool, place=Place(cpu), stop_gradient=True, [])) Tuple[Tensor, Tensor, Tensor][来源]
仅转发一个块
- Args:
- xs (paddle.Tensor): chunk input, with shape (b=1, time, mel-dim),
其中 time == (chunk_size - 1) * subsample_rate + subsample.right_context + 1
offset (int): 编码器输出时间戳的当前偏移量required_cache_size (int): 下一个块所需的缓存大小
计算 >=0: 实际缓存大小 <0: 意味着需要所有历史缓存
- att_cache (paddle.Tensor): cache tensor for KEY & VALUE in
变换器/顺序者注意力,其形状为 (elayers, head, cache_t1, d_k * 2),其中 head * d_k == 隐藏维度 和 cache_t1 == 块大小 * 剩余解码块数量。
- cnn_cache (paddle.Tensor): cache tensor for cnn_module in conformer,
(elayers, b=1, hidden-dim, cache_t2),其中 cache_t2 == cnn.lorder - 1
- Returns:
- paddle.Tensor: output of current input xs,
形状为 (b=1, chunk_size, hidden-dim)。
- paddle.Tensor: new attention cache required for next chunk, with
动态形状 (elayers, head, ?, d_k * 2) 取决于所需的缓存大小。
- paddle.Tensor: new conformer cnn cache required for next chunk, with
与原始 cnn_cache 形状相同。
- class paddlespeech.s2t.modules.encoder.TransformerEncoder(input_size: int, output_size: 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, static_chunk_size: int = 0, use_dynamic_chunk: bool = False, global_cmvn: Optional[Layer] = None, use_dynamic_left_chunk: bool = False)[来源]
基类:
BaseEncoder转换器编码模块。
方法
__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_lens[, decoding_chunk_size, ...])在张量中嵌入位置。参数: xs:填充输入张量 (B, L, D) xs_lens:输入长度 (B) decoding_chunk_size:动态块的解码块大小 0:训练的默认值,使用随机动态块。 <0: 解码时,使用完整块。 >0:解码时,使用设置的固定块大小。 num_decoding_left_chunks:剩余块的数量,这用于解码, 块大小为 decoding_chunk_size。 >=0:使用 num_decoding_left_chunks <0:使用所有剩余块 返回: 编码器输出张量,长度和掩码。
forward_chunk(xs, offset, required_cache_size)仅前进一个块 参数: xs (paddle.Tensor): 音频特征输入块,[B=1, T, D],其中 T==(chunk_size-1)*subsampling_rate + subsample.right_context + 1 offset (int): 编码器输出时间戳的当前偏移量 required_cache_size (int): 下一个块所需的缓存大小 >=0: 实际缓存大小 <0: 意味着需要所有历史缓存 att_cache(paddle.Tensor): transformer/conformer 注意力中的键和值的缓存张量。形状是 (elayers, head, cache_t1, d_k * 2),其中`head * d_k == hidden-dim` 和 cache_t1 == chunk_size * num_decoding_left_chunks. cnn_cache (paddle.Tensor): conformer中cnn_module的缓存张量, (elayers, B=1, hidden-dim, cache_t2),其中 cache_t2 == cnn.lorder - 1 返回: paddle.Tensor: 当前输入 xs 的输出,(B=1, chunk_size, hidden-dim) paddle.Tensor: 下一个块所需的新注意力缓存,动态形状 (elayers, head, T, d_k*2) 取决于 required_cache_size paddle.Tensor: 下一个块所需的新 conformer cnn 缓存,形状与原始 cnn_cache 相同。
forward_chunk_by_chunk(xs, decoding_chunk_size)逐块前向输入,像流媒体一样使用块大小
forward_one_step(xs, masks[, cache])编码输入帧。
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()将此层及其所有子层设置为训练模式。
向后
输出大小
注册状态字典钩子