无需数学就能写AI,MIT提出AI专用编程语言Gen( 六 )

end

end

其次,研究人员编写了一个推理程序,用于操纵模型的 Execution Traces。推理程序是常规的 Julia 代码,并利用 Gen 的标准推理库。

下面的推理程序会输入数据集,并迭代地运行 MCMC 算法,以拟合 slope 和 intercept 参数:

function my_inference_program(xs::Vector{Float64}, ys::Vector{Float64}, num_iters::Int)

# Create a set of constraints fixing the

# y coordinates to the observed y values

constraints = choicemap()

for (i, y) in enumerate(ys)

constraints["y-$i"] = y

end

# Run the model, constrained by `constraints`,

# to get an initial execution trace

推荐阅读