EmbeddingBag#
- class torch.ao.nn.quantized.EmbeddingBag(num_embeddings, embedding_dim, max_norm=None, norm_type=2.0, scale_grad_by_freq=False, mode='sum', sparse=False, _weight=None, include_last_offset=False, dtype=torch.quint8)[原始碼]#
一個量化的 EmbeddingBag 模組,使用量化的打包權重作為輸入。我們採用了與 torch.nn.EmbeddingBag 相同的介面,有關文件請參閱 https://pytorch.com.tw/docs/stable/generated/torch.nn.EmbeddingBag.html。
與
EmbeddingBag類似,屬性將在模組建立時被隨機初始化,並在之後被覆蓋。- 變數
weight (Tensor) – 模組的不可學習的量化權重,形狀為 。
- 示例:
>>> m = nn.quantized.EmbeddingBag(num_embeddings=10, embedding_dim=12, include_last_offset=True, mode='sum') >>> indices = torch.tensor([9, 6, 5, 7, 8, 8, 9, 2, 8, 6, 6, 9, 1, 6, 8, 8, 3, 2, 3, 6, 3, 6, 5, 7, 0, 8, 4, 6, 5, 8, 2, 3]) >>> offsets = torch.tensor([0, 19, 20, 28, 28, 32]) >>> output = m(indices, offsets) >>> print(output.size()) torch.Size([5, 12])