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_)
我还尝试降低精度值(所需的十进制位置)。此问题仅对几个内核出现。
我能想到的两件事可能导致您的问题:
- 该算法使用随机种子
- 安装过程中的内核超标 会更改
我会尝试将随机种子设置为常数然后重试。如果那不起作用,您会介意分享哪些内核未能使测试失败?
(这更多是评论,但我的特权并不高。)