| 35 | } |
| 36 | |
| 37 | void 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 | |
| 57 | void TestSoftprobMultiClassBasic(const Context* ctx) { |
| 58 | std::vector<std::pair<std::string, std::string>> args { |
no test coverage detected