gpt4 book ai didi

curve-fitting - ValueError : operands could not be broadcast together with shapes (0) (26) when using optimize. 曲线

转载 作者:行者123 更新时间:2023-12-02 00:09:25 30 4
gpt4 key购买 nike

我正在尝试为我的脚本生成的某些数据获取最佳拟合线。这是我的:

import numpy as np
import scipy as sp
.
.
.
def func(x, a, b, c):
return a*np.exp(-b*x) + c
popt, pcov = sp.optimize.curve_fit(func, numgelt, turnsG)

我一直收到这个错误:

ValueError: operands could not be broadcast together with shapes (0) (26)

我已经检查过,这两个数组(numgelt 和 turnsG)的大小绝对相同。我还确保条目是 float 的。谢谢!

最佳答案

我遇到了同样的问题,直到我意识到我一直在使用列表而不是 Numpy 数组。转换为数组为我修复了它。

关于curve-fitting - ValueError : operands could not be broadcast together with shapes (0) (26) when using optimize. 曲线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16220425/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com