44 const std::string &methodName,
Model &model) {
45 static const std::unordered_map<std::string,
46 std::function<void(T *,
Model &)>>
47 methods = {{
"onTrainBegin",
48 [](T *callback,
Model &model) {
49 return callback->onTrainBegin(model);
52 [](T *callback,
Model &model) {
53 return callback->onTrainEnd(model);
56 [](T *callback,
Model &model) {
57 return callback->onEpochBegin(model);
60 [](T *callback,
Model &model) {
61 return callback->onEpochEnd(model);
64 [](T *callback,
Model &model) {
65 return callback->onBatchBegin(model);
67 {
"onBatchEnd", [](T *callback,
Model &model) {
68 return callback->onBatchEnd(model);
71 auto it = methods.find(methodName);
73 if (it == methods.end())
return;
75 it->second(callback.get(), model);