Skip to content

[Bug]: call cmap object on torch.tensor will output first element all 0 #23132

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy