如何修复 pymc4 中的错误消息“在回复完成之前取消执行请求消息的未来”

ydq*_*ydq 5 python jupyter

我正在使用 pymc4 运行我的贝叶斯模型。但是当我执行示例方法时,它崩溃了。我想知道我的问题出在哪里。这是我的代码

import pymc as pm
import numpy as np
import aesara.tensor as at
from aesara.compile.ops import as_op
assert pm.__version__ == '4.0.0b6'


data = [0.05 + i for i in np.random.uniform(-0.05, 0.2, 1000)]

##https://www.pymc.io/projects/docs/en/latest/learn/core_notebooks/pymc_overview.html?highlight=switch#case-study-2-coal-mining-disasters 
## example :Arbitary deterministics. I changed the function in the url above
@as_op(itypes=[at.dscalar, at.dscalar], otypes=[at.dscalar])
def piecewise_timespan_label(back, forward):
    td = forward - back
    if td >= 12:
        return 1
    elif td >= 8:
        return 0.9
    elif td >= 6:
        return 0.8
    elif td >= 4:
        return 0.6
    elif td >= 2:
        return 0.4
    elif td >= 1:
        return 0.2
    elif td >= 0.5:
        return 0.1
    elif td >= 0.05:
        return 0.08
    else:
        return 0.05


with pm.Model() as model_deterministic:
    back = pm.Exponential("back", 0.2)
    forward = pm.Exponential("forward", 0.2)
    ratio_est = piecewise_timespan_label(back, forward)
    eps = pm.HalfCauchy("eps", 0.5)
    y = pm.Normal("y", ratio_est, sigma=eps, observed=data)

with model_deterministic:
    idata = pm.sample(1000)

print('here')
Run Code Online (Sandbox Code Playgroud)

这是我的错误消息:

Canceled future for execute_request message before replies were done
The Kernel crashed while executing code in the the current cell or a previous cell. Please review the code in the cell(s) to identify a possible cause of the failure. Click here for more info. View Jupyter log for further details.
Run Code Online (Sandbox Code Playgroud)

我的系统是window 10 21H2 我在vscode jupyter上运行它:v2022.4.1021342353

埃莎拉:2.5.1

pymc:'4.0.0b6'

numpy:1.23.0rc1

预先感谢您的回复

Dro*_*dux 0

这可能是由于您的计算机缺乏可用内存。在 Windows 上,您可以通过打开任务管理器并在运行代码时查看“性能”选项卡中的内存使用情况来轻松检查这一点。

解决此问题的一种方法是仅采用数据集的子集。如果您不想这样做,您可以尝试使用 Colab 等。

希望能帮助到你。