我正在使用pymc3来寻找一个最适合的三维表面。这是我正在使用的代码。
with Model() as model:
# specify glm and pass in data. The resulting linear model, its likelihood and
# and all its parameters are automatically added to our model.
glm.glm('z ~ x**2 + y**2 + x + y + np.sin(x) + np.cos(y)' , flatimage)
start = find_MAP()
step = NUTS(scaling=start) # Instantiate MCMC sampling algorithm
trace = sample(2000, step, progressbar=False) # draw 2000 posterior samples using NUTS sampling
我这行有个错误:
glm.glm('z ~ x**2 + y**2 + x + y + np.sin(x) + np.cos(y)' , flatimage)
错误是:
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
我试着通过把sin(x)和cos(y)改成np.sin(x)和np.cos(y)来解决这个问题,但这不起作用,我不知道还能做什么。
我认为这个问题与你对
flatimage
的定义有关。需要为glm模块标记数据才能工作。像这样的:查看this示例以了解其他详细信息。
相关问题 更多 >
编程相关推荐