Skip to content

Negative mask unsupport (ByteTensor) in Pytorch 0.3 #4066

@jiesutd

Description

@jiesutd

When I use the negative mask like :

mask = torch.autograd.Variable(torch.zeros((3,4 ))).byte()
mask = 1- mask
Pytorch 0.3 shows "RuntimeError: neg is not implemented for type torch.ByteTensor"

It is also observed in Pytorch 0.2, but can be solved in Pytorch 0.2 using:
mask = 1 + (-1) *mask

While in Pytorch 0.3, the previous solution gives the "RuntimeError: value cannot be converted to type uint8_t without overflow: -1".

It is caused by the ByteTensor does not support negative operation. So I use mask = (1-mask.long()).byte() to solve the problem, but it is not elegant.

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