@details Forward prop is applied to all layers, except input * layers. It is assumed that input layers have already loaded data. */
| 56 | * layers. It is assumed that input layers have already loaded data. |
| 57 | */ |
| 58 | EvalType 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 | |
| 90 | struct DefaultErrorReporter |
| 91 | { |
no test coverage detected