Skip to content

Feature request: user specified default values for nn.Embedding #702

Closed

Description

@shawnjhenry

Hi,

I'm trying to create a module that, given an n-dimensional LongTensor returns an n+2 dimensional FloatTensor arranged correspondingly from slices of a 3-dimensional FloatTensor. In theory this can be accomplished with nn.Embedding plus a reshape, except that I need the matrix corresponding to the padding_idx to be the identity matrix instead of a zero matrix. This could be accomplished by allowing the user to specify what default vector is returned corresponding to padding_idx. Would that be possible?

Thanks,
Shawn

Activity

  1. soumith commented on Feb 11, 2017

    @soumith
    Collaborator

    this is certainly possible to implement, we have to change our C backends slightly to accommodate this. will put it on a list of things to do

  2. added a commit that references this issue on Feb 15, 2017
  3. added
    feature
    and removed on Apr 1, 2019
  4. added
    module: nn
    triaged
    on Aug 12, 2019
  5. jbschlosser commented on May 18, 2021

    @jbschlosser
    Contributor

    Closing this because it is possible to specify a custom value to use for the vector at padding_idx. An example of doing so is in the Embedding docs.

  6. added a commit that references this issue on Sep 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featuremodule: nntriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions