Skip to content

RFC: consider adding the one-hot array creation function #787

Closed as not planned
@NeilGirdhar

Description

@NeilGirdhar

One-hot is a very common array creation function in machine learning. It might be worth considering its addition.

Various implementations have different semantics:

  • pytorch (Optionally infers the number of classes, cannot select axis)
  • tensorflow (can choose on and off values)
  • jax

From an organization standpoint, I think it probably would belong alongside other creation functions like eye.

Alternatively, one-hot could be generalized to a broadcastable unit-impulse, which is already in scipy. Whereas one-hot chooses one element in a vector to be on, unit-impulse chooses one element in an array to be on.

One-hot is a generalization of the standard (elementary) basis vector that is sometimes requested—a generalization because it supports broadcasting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    API extensionAdds new functions or objects to the API.RFCRequest for comments. Feature requests and proposed changes.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions