MCPcopy Create free account
hub / github.com/dmlc/xgboost / TestSoftmaxMultiClassBasic

Function TestSoftmaxMultiClassBasic

tests/cpp/objective/test_multiclass_obj.cc:37–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37void TestSoftmaxMultiClassBasic(const Context* ctx) {
38 std::vector<std::pair<std::string, std::string>> args{
39 std::pair<std::string, std::string>("num_class", "3")};
40
41 std::unique_ptr<ObjFunction> obj{ObjFunction::Create("multi:softmax", ctx)};
42 obj->Configure(args);
43 CheckConfigReload(obj, "multi:softmax");
44
45 HostDeviceVector<bst_float> io_preds = {2.0f, 0.0f, 1.0f,
46 1.0f, 0.0f, 2.0f};
47 std::vector<bst_float> out_preds = {0.0f, 2.0f};
48 obj->PredTransform(&io_preds);
49
50 auto& preds = io_preds.HostVector();
51
52 for (int i = 0; i < static_cast<int>(io_preds.Size()); ++i) {
53 EXPECT_NEAR(preds[i], out_preds[i], 0.01f);
54 }
55}
56
57void TestSoftprobMultiClassBasic(const Context* ctx) {
58 std::vector<std::pair<std::string, std::string>> args {

Callers 2

TESTFunction · 0.85
TESTFunction · 0.85

Calls 4

CheckConfigReloadFunction · 0.85
ConfigureMethod · 0.45
PredTransformMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected