添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
qq_38621899 2022-11-10 08:38 采纳率: 0%
浏览 165

python cannot pickle 'Tensor' object

在pycharm中用matplotlib绘制图像,会报错,代码以及报错信息如下,一直无法解决,请教大家这个该怎么办

代码:
from matplotlib import pyplot as plt # matplotlib 是 Python 的绘图库

plt.rcParams['figure.figsize'] = (8.0, 6.0)
plt.scatter(X_train, y_train, facecolor="none", edgecolor='#e4007f', s=50, label="train data")
#plt.scatter(X_test, y_test, facecolor="none", edgecolor="r", s=50, label="test data")
plt.plot(X_underlying, y_underlying, c='#000000', label=r"$\sin(2\pi x)$")
plt.legend(fontsize='x-large')
plt.savefig('ml-vis2.pdf')
plt.show()

报错信息:
W1110 08:32:06.620424 20492 gpu_resources.cc:61] Please NOTE: device: 0, GPU Compute Capability: 8.6, Driver API Version: 11.6, Runtime API Version: 10.2
W1110 08:32:06.630646 20492 gpu_resources.cc:91] device: 0, cuDNN Version: 7.6.
Traceback (most recent call last):
File "D:\document wyl\编程自学\pythonProject\2.3多项式回归.py", line 69, in
plt.plot(X_underlying, y_underlying, c='#000000', label=r"$\sin(2\pi x)$")
File "D:\install wyl\program\anaconda\envs\paddle\lib\site-packages\matplotlib\pyplot.py", line 2740, in plot
return gca().plot(
File "D:\install wyl\program\anaconda\envs\paddle\lib\site-packages\matplotlib\axes _axes.py", line 1662, in plot
lines = [*self._get_lines(*args, data=data, **kwargs)]
File "D:\install wyl\program\anaconda\envs\paddle\lib\site-packages\matplotlib\axes _base.py", line 311, in call
yield from self._plot_args(
File "D:\install wyl\program\anaconda\envs\paddle\lib\site-packages\matplotlib\axes _base.py", line 544, in _plot_args
return [l[0] for l in result]
File "D:\install wyl\program\anaconda\envs\paddle\lib\site-packages\matplotlib\axes _base.py", line 544, in
return [l[0] for l in result]
File "D:\install wyl\program\anaconda\envs\paddle\lib\site-packages\matplotlib\axes _base.py", line 537, in
result = (make_artist(x[:, j % ncx], y[:, j % ncy], kw,
File "D:\install wyl\program\anaconda\envs\paddle\lib\site-packages\matplotlib\axes _base.py", line 351, in _makeline
seg = mlines.Line2D(x, y, **kw)
File "D:\install wyl\program\anaconda\envs\paddle\lib\site-packages\matplotlib _api\deprecation.py", line 454, in wrapper
return func(*args, **kwargs)
File "D:\install wyl\program\anaconda\envs\paddle\lib\site-packages\matplotlib\lines.py", line 412, in init
self.set_data(xdata, ydata)
File "D:\install wyl\program\anaconda\envs\paddle\lib\site-packages\matplotlib\lines.py", line 650, in set_data
self.set_xdata(x)
File "D:\install wyl\program\anaconda\envs\paddle\lib\site-packages\matplotlib\lines.py", line 1279, in set_xdata
self._xorig = copy.copy(x)
File "D:\install wyl\program\anaconda\envs\paddle\lib\copy.py", line 92, in copy
rv = reductor(4)
TypeError: cannot pickle 'Tensor' object

0

  • 编辑 收藏 删除 结题
  • 追加酬金 (90%的用户在追加酬金后获得了解决方案)

    当前问题酬金

    ¥ 0 (可追加 ¥500)

    支付方式

    余额支付

    余额: ¥ 499

    扫码支付

    提供问题酬金的用户不参与问题酬金结算和分配

    支付即为同意 《付费问题酬金结算规则》

    3 条回答 默认 最新

    查看更多回答(-1条) 报告相同问题?

    问题事件

    • 创建了问题 11月10日

    悬赏问题

    • ¥15 蓝屏dump之irql_not_less_or_equal ntoskrnl.exe 用SPSS建立ARIMA模型为什么R2都等于1 如何使用verilog语言设计一个卷积交织器 关于#数据结构#的问题:画出该代码的函数算法流程图(语言-c语言) 迷宫中的A*算法应用 JAVA设计媒体库管理系统 ldif3读取ldif文件报错:ValueError: subsection not found 求“河北省保定市白洋淀地区”矢量边界