【发布时间】:2021-10-27 15:57:23
【问题描述】:
刚开始使用 Pyorch,我正在尝试使用 Matplotlib 将一个非常简单的一维数组张量绘制到直方图上。
torch.manual_seed(8436)
a = torch.Tensor(1000)
a.normal_(0, 2.) #This will fill our array with a normal distribution
plt.hist(a);
However, the result is strange...,只是由一堆垂直的彩色线条组成。
The result I am supposed to get, which I do when entering:
plt.hist(a.numpy())
是正常的直方图。
提前感谢您的帮助!
【问题讨论】:
标签: python matplotlib plot pytorch tensor