MCPcopy Create free account
hub / github.com/LBANN/lbann / compute_objective_function

Function compute_objective_function

src/callbacks/check_gradients.cpp:58–88  ·  view source on GitHub ↗

@details Forward prop is applied to all layers, except input * layers. It is assumed that input layers have already loaded data. */

Source from the content-addressed store, hash-verified

56 * layers. It is assumed that input layers have already loaded data.
57 */
58EvalType compute_objective_function(model& m)
59{
60 const auto& c = static_cast<SGDExecutionContext&>(m.get_execution_context());
61 m.get_activation_reference_counter().clear();
62
63 // Forward prop, skipping input layers
64
65 if (m.is_subgraph_parallelism_enabled()) {
66 for (auto&& l : m.get_layers()) {
67 if (dynamic_cast<input_layer<DataType>*>(l) == nullptr &&
68 l->get_run_layer_in_subgraph()) {
69 l->forward_prop();
70 }
71 }
72 }
73 else // sub-graph parallelism not enabled
74 {
75 for (auto&& l : m.get_layers()) {
76 if (dynamic_cast<input_layer<DataType>*>(l) == nullptr) {
77 l->forward_prop();
78 }
79 }
80 }
81
82 // Get objective function value
83 auto&& obj = m.get_objective_function();
84 const auto mode = c.get_execution_mode();
85 const auto mini_batch_size = m.get_current_mini_batch_size();
86 obj->start_evaluation(mode, mini_batch_size);
87 return obj->finish_evaluation(mode, mini_batch_size);
88}
89
90struct DefaultErrorReporter
91{

Callers 2

operator()Method · 0.85
do_check_gradientsMethod · 0.85

Calls 10

get_layersMethod · 0.80
clearMethod · 0.45
forward_propMethod · 0.45
get_execution_modeMethod · 0.45
start_evaluationMethod · 0.45
finish_evaluationMethod · 0.45

Tested by

no test coverage detected