嵌入 ¶
- 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]¶
一个具有量化打包权重的量化嵌入模块。我们采用与 torch.nn.Embedding 相同的接口,请参阅 https://pytorch.org/docs/stable/generated/torch.nn.Embedding.html 以获取文档。
与
Embedding
相似,属性将在模块创建时随机初始化,之后将被覆盖- 变量:
weight(张量)- 模块的非可学习量化权重,形状为 。
- 示例::
>>> 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])