Skip to content

torch.from_numpy incorrect when dtype=int64 and certain numpy flags are set #217

@soumith

Description

@soumith
import scipy.misc
lena = scipy.misc.lena()
print(lena.shape)
print(lena[90,90])
print(lena.dtype)

(100, 212)
151
int64

img = torch.from_numpy(lena)
print(img.size())
print(img[90,90])

torch.Size([100, 212])
-13846360384743979

img = torch.from_numpy(lena.astype(float))
print(img.size())
print(img[90,90])

torch.Size([100, 212])
151.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions