1
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_)
我也試着降低精度值(所需的小數位數)。這個問題僅在少數內核中出現。裝修 尷尬平行幫手不返回不同的'n_jobs'參數相同的結果
我會嘗試設置期間
- 該算法採用隨機種子
- 內核超參數改變:我能想到的,
的隨機種子液的伎倆。 –