paddlespeech.s2t 包

class paddlespeech.s2t.LayerDict(modules: Optional[Mapping[str, Layer]] = None)[来源]

基础: Layer

在字典中保存子模块。

LayerDict 可以像普通的 Python 字典一样被索引,但是它包含的模块是经过正确注册的,并且对所有 Layer 方法都是可见的。

LayerDict 是一个 有序的 字典,尊重

  • 插入的顺序,以及

  • update() 中,合并的顺序是 OrderedDictdict(从 Python 3.6 开始)或另一个 LayerDict(传递给 update() 的参数)。

请注意,update() 与其他无序映射类型(例如,Python版本3.6之前的普通dict)合并时不保留合并映射的顺序。

Args:
modules (iterable, optional): a mapping (dictionary) of (string: module)

或可迭代的键值对,类型为(字符串,模块)

示例:

class MyModule(nn.Layer):
    def __init__(self):
        super(MyModule, self).__init__()
        self.choices = nn.LayerDict({
                'conv': nn.Conv2d(10, 10, 3),
                'pool': nn.MaxPool2d(3)
        })
        self.activations = nn.LayerDict([
                ['lrelu', nn.LeakyReLU()],
                ['prelu', nn.PReLU()]
        ])

    def forward(self, x, choice, act):
        x = self.choices[choice](x)
        x = self.activations[act](x)
        return x

方法

__call__(*inputs, **kwargs)

将self作为一个函数调用。

add_parameter(name, parameter)

添加一个参数实例。

add_sublayer(name, sublayer)

添加一个子层实例。

apply(fn)

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

buffers([include_sublayers])

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

children()

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

clear()

从 LayerDict 中移除所有项。

clear_gradients()

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

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

为该层创建参数。

create_tensor([name, persistable, dtype])

为该层创建张量。

create_variable([name, persistable, dtype])

为该层创建张量。

eval()

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

extra_repr()

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

forward(*inputs, **kwargs)

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

full_name()

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

items()

返回一个可迭代的 LayerDict 键/值对。

keys()

返回一个可迭代的 LayerDict 键。

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])

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

pop(key)

从 LayerDict 中移除键并返回其模块。

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

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

update(modules)

使用映射或可迭代的键值对更新 LayerDict,覆盖现有的键。

values()

返回一个可迭代的LayerDict值。

向后

注册状态字典钩子

clear() None[来源]

从LayerDict中移除所有项目。

items() Iterable[Tuple[str, Layer]][来源]

返回一个可迭代的 LayerDict 键/值对。

keys() Iterable[str][来源]

返回一个可迭代的 LayerDict 键。

pop(key: str) Layer[来源]

从LayerDict中移除键并返回其模块。

Args:

key (string):要从 LayerDict 中弹出的键

update(modules: Mapping[str, Layer]) None[来源]

使用映射或可迭代对象中的键值对更新 LayerDict,覆盖现有键。

注意

如果 modules 是一个 OrderedDict、一个 LayerDict,或者 一个键值对的可迭代集合,那么新元素的顺序将被保留。

Args:
modules (iterable): a mapping (dictionary) from string to Layer,

或一个类型为 (字符串, Layer) 的键值对可迭代对象

values() Iterable[Layer][来源]

返回一个可迭代的 LayerDict 值。

paddlespeech.s2t.broadcast_shape(shp1, shp2)[来源]
paddlespeech.s2t.cat(xs, dim=0)[来源]
paddlespeech.s2t.contiguous(xs: Tensor) Tensor[来源]
paddlespeech.s2t.fill_(xs: Tensor, value: Union[float, int]) Tensor[来源]
paddlespeech.s2t.func_float(x: Tensor) Tensor[来源]
paddlespeech.s2t.func_int(x: Tensor) Tensor[来源]
paddlespeech.s2t.func_long(x: Tensor)[来源]
paddlespeech.s2t.is_broadcastable(shp1, shp2)[来源]
paddlespeech.s2t.item(x: Tensor)[来源]
paddlespeech.s2t.masked_fill(xs: Tensor, mask: Tensor, value: Union[float, int])[来源]
paddlespeech.s2t.masked_fill_(xs: Tensor, mask: Tensor, value: Union[float, int]) Tensor[来源]
paddlespeech.s2t.new_full(x: Tensor, size: Union[List[int], Tuple[int], Tensor], fill_value: Union[float, int, bool, Tensor], dtype=None)[来源]
paddlespeech.s2t.repeat(xs: Tensor, *size: Any) Tensor[来源]
paddlespeech.s2t.to(x: Tensor, *args, **kwargs) Tensor[来源]
paddlespeech.s2t.tolist(x: Tensor) List[Any][来源]
paddlespeech.s2t.type_as(x: Tensor, other: Tensor) Tensor[来源]
paddlespeech.s2t.view(xs: Tensor, *args: int) Tensor[来源]
paddlespeech.s2t.view_as(xs: Tensor, ys: Tensor) Tensor[来源]

子包