【问题标题】:pymc3 multiple gaussian process regressionpymc3 多重高斯过程回归
【发布时间】:2017-08-08 21:03:24
【问题描述】:

我正在尝试通过扩展https://pymc-devs.github.io/pymc3/notebooks/GP-introduction.html 中的第一个示例来运行具有两个特征的高斯过程回归

n = 20
X = np.array([list(a) for a in zip(np.sort(3*np.random.rand(n)), np.sort(3*np.random.rand(n)))])
y = np.random.normal(size=n)

with pm.Model() as model:
    # priors on the covariance function hyperparameters
    l = np.array([pm.Uniform('l1', 0, 10), pm.Uniform('l2', 0, 10)])

    # uninformative prior on the function variance
    log_s2_f = pm.Uniform('log_s2_f', lower=-10, upper=5)
    s2_f = pm.Deterministic('s2_f', tt.exp(log_s2_f))

    # uninformative prior on the noise variance
    log_s2_n = pm.Uniform('log_s2_n', lower=-10, upper=5)
    s2_n = pm.Deterministic('s2_n', tt.exp(log_s2_n))

    # covariance functions for the function f and the noise
    f_cov = s2_f * pm.gp.cov.ExpQuad(input_dim=2, lengthscales=l)

    y_obs = pm.gp.GP('y_obs', cov_func=f_cov, sigma=s2_n, observed={'X':X, 'Y':y})

这里Xy 的输入用于测试输入的形状。 当我运行代码时,我得到一个 theano AsTensorError 错误,它在 pymc3 中被追溯到这个

/usr/local/lib/python2.7/site-packages/pymc3/gp/cov.pyc in square_dist(self, X, Z)
    124 
    125     def square_dist(self, X, Z):
--> 126         X = tt.mul(X, 1.0 / self.lengthscales)
    127         Xs = tt.sum(tt.square(X), 1)
    128         if Z is None:

是否可以在 pymc3 中运行多重高斯回归?如果是这样,我确定我在某处弄乱了尺寸。

【问题讨论】:

    标签: python-2.7 theano pymc3


    【解决方案1】:

    我在以下博客中找到了我的问题的解决方案,这显然是 pymc3 的参考点。

    https://discourse.pymc.io/t/multidimensional-input-using-gaussian-process/128,

    不是将协方差先验定义为分布数组,而是将它们定义为具有相应数量的分量的多项分布。通过更改上面的以下代码行,一切都按预期工作

    with pm.Model() as model:
        # priors on the covariance function hyperparameters
        l = pm.Gamma('l', 1, 1, shape=2)
    

    【讨论】:

      猜你喜欢
      • 2015-09-10
      • 2018-12-06
      • 2016-09-29
      • 2018-10-15
      • 2020-05-20
      • 2020-07-16
      • 2021-03-08
      相关资源
      最近更新 更多