Use matrix for gradient. (#9508)
- Use the `linalg::Matrix` for storing gradients. - New API for the custom objective. - Custom objective for multi-class/multi-target is now required to return the correct shape. - Custom objective for Python can accept arrays with any strides. (row-major, column-major)
This commit is contained in:
@@ -21,15 +21,13 @@ TEST(Updater, Prune) {
|
||||
std::vector<std::pair<std::string, std::string>> cfg;
|
||||
cfg.emplace_back("num_feature", std::to_string(kCols));
|
||||
cfg.emplace_back("min_split_loss", "10");
|
||||
Context ctx;
|
||||
|
||||
// These data are just place holders.
|
||||
HostDeviceVector<GradientPair> gpair =
|
||||
{ {0.50f, 0.25f}, {0.50f, 0.25f}, {0.50f, 0.25f}, {0.50f, 0.25f},
|
||||
{0.25f, 0.24f}, {0.25f, 0.24f}, {0.25f, 0.24f}, {0.25f, 0.24f} };
|
||||
std::shared_ptr<DMatrix> p_dmat {
|
||||
RandomDataGenerator{32, 10, 0}.GenerateDMatrix() };
|
||||
|
||||
Context ctx;
|
||||
linalg::Matrix<GradientPair> gpair
|
||||
{{ {0.50f, 0.25f}, {0.50f, 0.25f}, {0.50f, 0.25f}, {0.50f, 0.25f},
|
||||
{0.25f, 0.24f}, {0.25f, 0.24f}, {0.25f, 0.24f}, {0.25f, 0.24f} }, {8, 1}, ctx.Device()};
|
||||
std::shared_ptr<DMatrix> p_dmat{RandomDataGenerator{32, 10, 0}.GenerateDMatrix()};
|
||||
|
||||
// prepare tree
|
||||
RegTree tree = RegTree{1u, kCols};
|
||||
|
||||
Reference in New Issue
Block a user