From 15a0d27eed1a852ab526eafe0dc9bf1eff457e4a Mon Sep 17 00:00:00 2001 From: terrytangyuan Date: Sat, 31 Oct 2015 12:40:19 -0400 Subject: [PATCH] Fixed bug in eta decay (+2 squashed commits) Squashed commits: [b67caf2] Fix build [365ceaa] Fixed bug in eta decay --- R-package/tests/testthat/test_custom_objective.R | 10 ---------- python-package/xgboost/training.py | 2 +- tests/python/test_models.py | 3 --- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/R-package/tests/testthat/test_custom_objective.R b/R-package/tests/testthat/test_custom_objective.R index a0590a9af..7407246c6 100644 --- a/R-package/tests/testthat/test_custom_objective.R +++ b/R-package/tests/testthat/test_custom_objective.R @@ -46,13 +46,3 @@ test_that("custom objective works", { expect_equal(class(bst), "xgb.Booster") expect_equal(length(bst$raw), 1064) }) - -test_that("different eta for each boosting round works", { - num_round <- 2 - watchlist <- list(eval = dtest, train = dtrain) - param <- list(max.depth=2, eta=1, nthread = 2, silent=1) - - bst <- xgb.train(param, dtrain, num_round, watchlist, learning_rates = c(0.2, 0.3)) -}) - - diff --git a/python-package/xgboost/training.py b/python-package/xgboost/training.py index dbb9cca27..500641745 100644 --- a/python-package/xgboost/training.py +++ b/python-package/xgboost/training.py @@ -123,7 +123,7 @@ def train(params, dtrain, num_boost_round=10, evals=(), obj=None, feval=None, best_msg = '' best_score_i = 0 - if isinstance(learning_rates, list) and len(learning_rates) < num_boost_round: + if isinstance(learning_rates, list) and len(learning_rates) != num_boost_round: raise ValueError("Length of list 'learning_rates' has to equal 'num_boost_round'.") for i in range(num_boost_round): diff --git a/tests/python/test_models.py b/tests/python/test_models.py index e4f2de5c2..295765d61 100644 --- a/tests/python/test_models.py +++ b/tests/python/test_models.py @@ -28,9 +28,6 @@ class TestModels(unittest.TestCase): # learning_rates as a list bst = xgb.train(param, dtrain, num_round, watchlist, learning_rates=[0.4, 0.3]) assert isinstance(bst, xgb.core.Booster) - # different length - num_round = 4 - self.assertRaises(ValueError, xgb.train, param, dtrain, num_round, watchlist, learning_rates=[0.4, 0.3, 0.2]) # learning_rates as a customized decay function def eta_decay(ithround, num_boost_round):