快捷方式

Embedding

class torch.ao.nn.quantized.Embedding(num_embeddings, embedding_dim, padding_idx=None, max_norm=None, norm_type=2.0, scale_grad_by_freq=False, sparse=False, _weight=None, dtype=torch.quint8)[source][source]

一个量化的 Embedding 模块,使用量化打包权重作为输入。我们采用了与 torch.nn.Embedding 相同的接口,请参阅 https://pytorch.ac.cn/docs/stable/generated/torch.nn.Embedding.html 获取文档。

类似于 Embedding,属性将在模块创建时随机初始化,稍后将被覆盖

变量

weight (Tensor) – 模块的非可学习量化权重,形状为 (num_embeddings,embedding_dim)(\text{num\_embeddings}, \text{embedding\_dim})

示例:
>>> m = nn.quantized.Embedding(num_embeddings=10, embedding_dim=12)
>>> indices = torch.tensor([9, 6, 5, 7, 8, 8, 9, 2, 8])
>>> output = m(indices)
>>> print(output.size())
torch.Size([9, 12])
classmethod from_float(mod, use_precomputed_fake_quant=False)[source][source]

从浮点模块创建量化 embedding 模块

参数

mod (Module) – 一个浮点模块,由 torch.ao.quantization 实用程序生成或由用户提供

文档

访问全面的 PyTorch 开发者文档

查看文档

教程

获取面向初学者和高级开发者的深度教程

查看教程

资源

查找开发资源并获得问题解答

查看资源