Skip to content

nn.Embedding with sparse=True ignores padding_idx #3506

@soumith

Description

@soumith

As reported here https://discuss.pytorch.org/t/bug-of-nn-embedding-when-sparse-true-and-padding-idx-is-set/9382 with repro.

When sparse=True, padding_idx should probably error out (as the easiest solution).
Alternatively, the gradients for padding_idx indices should be zeroed out explicitly in the sparse=True backward codepath.

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