Skip to content

Any easy approach to apply nn.Softmax() along each dimension? #1260

@yuandong-tian

Description

@yuandong-tian

Currently nn.Softmax() can only be applied on 2D tensor. Is that possible we can specify dimension? E.g.,

x = torch.FloatTensor(128, 5, 27)
softmax = nn.Softmax(axis=1)
y = softmax(Variable(x))
y.size()

y.size() == x.size() but y's second dimension (5) has been applied softmax operation.

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