Refactor tests with data generator. (#5439)
This commit is contained in:
@@ -12,7 +12,7 @@ TEST(Linear, GPUCoordinate) {
|
||||
size_t constexpr kRows = 10;
|
||||
size_t constexpr kCols = 10;
|
||||
|
||||
auto mat = xgboost::CreateDMatrix(kRows, kCols, 0);
|
||||
auto mat = xgboost::RandomDataGenerator(kRows, kCols, 0).GenerateDMatix();
|
||||
auto lparam = CreateEmptyGenericParam(GPUIDX);
|
||||
|
||||
LearnerModelParam mparam;
|
||||
@@ -24,15 +24,13 @@ TEST(Linear, GPUCoordinate) {
|
||||
xgboost::LinearUpdater::Create("gpu_coord_descent", &lparam));
|
||||
updater->Configure({{"eta", "1."}});
|
||||
xgboost::HostDeviceVector<xgboost::GradientPair> gpair(
|
||||
(*mat)->Info().num_row_, xgboost::GradientPair(-5, 1.0));
|
||||
mat->Info().num_row_, xgboost::GradientPair(-5, 1.0));
|
||||
xgboost::gbm::GBLinearModel model{&mparam};
|
||||
|
||||
model.LazyInitModel();
|
||||
updater->Update(&gpair, (*mat).get(), &model, gpair.Size());
|
||||
updater->Update(&gpair, mat.get(), &model, gpair.Size());
|
||||
|
||||
ASSERT_EQ(model.bias()[0], 5.0f);
|
||||
|
||||
delete mat;
|
||||
}
|
||||
|
||||
TEST(GPUCoordinate, JsonIO) {
|
||||
|
||||
Reference in New Issue
Block a user