Julia 中的@ad 和@addr 宏是什么?
What are @ad and @addr macros in Julia?
我正在查看来自 here 的 Julia 中 Gen
模块的示例,我偶然发现了这段代码:
@compiled @gen function generate_datum(x::Float64, prob_outlier::Float64, noise::Float64,
@ad(slope::Float64), @ad(intercept::Float64))
if @addr(bernoulli(prob_outlier), :is_outlier)
(mu, std) = (0., 10.)
else
(mu, std) = (x * slope + intercept, noise)
end
return @addr(normal(mu, std), :y)
end
抛出
UndefVarError: @addr not defined
@ad
也一样,我怀疑是同一回事。由于我是 Julia 的新手并且搜索没有 return 任何模糊相关的东西,我被卡住了。有人可以帮忙吗?
根据 https://github.com/probcomp/Gen/issues/161,您的 link 指向的文件不再是存储库的一部分。那些宏被删除了,master 分支反映了这一点!如果您想 运行 这些示例,则需要切换到 Gen
的旧版本。
我正在查看来自 here 的 Julia 中 Gen
模块的示例,我偶然发现了这段代码:
@compiled @gen function generate_datum(x::Float64, prob_outlier::Float64, noise::Float64,
@ad(slope::Float64), @ad(intercept::Float64))
if @addr(bernoulli(prob_outlier), :is_outlier)
(mu, std) = (0., 10.)
else
(mu, std) = (x * slope + intercept, noise)
end
return @addr(normal(mu, std), :y)
end
抛出
UndefVarError: @addr not defined
@ad
也一样,我怀疑是同一回事。由于我是 Julia 的新手并且搜索没有 return 任何模糊相关的东西,我被卡住了。有人可以帮忙吗?
根据 https://github.com/probcomp/Gen/issues/161,您的 link 指向的文件不再是存储库的一部分。那些宏被删除了,master 分支反映了这一点!如果您想 运行 这些示例,则需要切换到 Gen
的旧版本。