You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用NeuralProphet调用fit()时遇epochs参数错误求助

NeuralProphet fit()方法传入epochs参数报错的解决办法

问题原因

你遇到的错误是因为NeuralProphet的API版本更新导致的:在0.5.x及以后的新版本中,epochs参数不再作为fit()方法的入参,而是需要在初始化模型对象时指定,或者通过训练参数字典传递。你参考的教程大概率是基于旧版本(0.4.x及之前)编写的,旧版本允许在fit()中直接传epochs。

解决方法

方法1:初始化模型时指定epochs

将epochs参数移到NeuralProphet的构造函数中:

m = NeuralProphet(epochs=1000)
m.fit(price, freq="M")

方法2:通过trainer_kwargs传递训练参数

如果需要在fit()阶段灵活调整训练参数,可以使用trainer_kwargs字典,其中max_epochs对应原有的epochs:

m = NeuralProphet()
m.fit(price, freq="M", trainer_kwargs={"max_epochs": 1000})

内容的提问来源于stack exchange,提问作者Jon Fredrik Heen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.16 08:00:59