Skip to content

padding_idx doesn't work. #1812

@TropComplique

Description

@TropComplique

Hi. There is no zero padding:

import torch
from torch.autograd import Variable
import torch.nn as nn

e = nn.Embedding(3, 2, padding_idx=0)
e.weight = nn.Parameter(torch.rand(3, 2))
print(e.weight)

Output:
Parameter containing:
0.5051 0.5076
0.9464 0.2811
0.4968 0.2109
[torch.FloatTensor of size 3x2]

indices = Variable(torch.LongTensor([0, 1, 2]))
e(indices)

Output:
Variable containing:
0.5051 0.5076
0.9464 0.2811
0.4968 0.2109
[torch.FloatTensor of size 3x2]

pytorch version: 0.1.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions