8000 [Bug]: call cmap object on torch.tensor will output first element all 0 · Issue #23132 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
[Bug]: call cmap object on torch.tensor will output first element all 0 #23132
Closed
@SanGilbert

Description

@SanGilbert

Bug summary

When I create camp object and call on torch.tensor, it output result with first element be all 0. But if I call tensor.numpy() explicity, everything went well. I do not know this is a problem of matplotlib or problem of pytorch.

Code for reproduction

import torch
from matplotlib import cm

cmap = cm.get_cmap("plasma")
i_tensor = abs(torch.randn([3,5,5]))
i_tensor = i_tensor/i_tensor.max()
i_numpy = i_tensor.numpy()
c_ts = cmap(i_tensor)[...,:3]
c_np = cmap(i_numpy)[...,:3]
print(c_ts[0])
print(c_np[0])

Actual outcome

[[[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]

[[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]

[[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]

[[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]

[[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]]

Expected outcome

with specific value

Additional information

No response

Operating system

No response

Matplotlib Version

3.3.4

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0