def test_n_jobs_parallel():
# Test to check the functioning of n_jobs parameter.
for kernel in kernels:
gpr1 = GaussianProcessRegressor(kernel=kernel, n_jobs=1,
n_restarts_optimizer=5).fit(X, y)
gpr2 = GaussianProcessRegressor(kernel=kernel, n_jobs=2,
n_restarts_optimizer=5).fit(X, y)
gpr3 = GaussianProcessRegressor(kernel=kernel, n_jobs=-1,
n_restarts_optimizer=5).fit(X, y)
y1, y1_cov = gpr1.predict(X, return_cov=True)
y2, y2_cov = gpr2.predict(X, return_cov=True)
y3, y3_cov = gpr3.predict(X, return_cov=True)
# Successfully passed tests
assert_almost_equal(y1, y2)
assert_almost_equal(y1, y3)
assert_almost_equal(y1_cov, y2_cov)
assert_almost_equal(y1_cov, y3_cov)
# Failing tests
assert_almost_equal(gpr1.alpha_, gpr2.alpha_)
assert_almost_equal(gpr1.alpha_, gpr3.alpha_)
assert_almost_equal(gpr1.log_marginal_likelihood_value_,
gpr2.log_marginal_likelihood_value_)
assert_almost_equal(gpr1.log_marginal_likelihood_value_,
gpr3.log_marginal_likelihood_value_)
我还尝试降低精度值(必需的小数位)。这个问题仅针对少数内核而出现。
答案 0 :(得分:1)
我能想到的两件事可能会导致你的问题:
我会尝试将随机种子设置为常量,然后重试。如果这不起作用,您是否介意分享哪些内核未通过测试?
(这更多是评论,但我的特权并不高......)