| 2532 | |
| 2533 | template <typename iterable_type, typename ...T> |
| 2534 | std::vector<output_label_type> process_batch (const iterable_type& data, size_t batch_size, T&& ...args) |
| 2535 | { |
| 2536 | std::vector<output_label_type> results(std::distance(data.begin(), data.end())); |
| 2537 | auto o = results.begin(); |
| 2538 | auto i = data.begin(); |
| 2539 | auto num_remaining = results.size(); |
| 2540 | while(num_remaining != 0) |
| 2541 | { |
| 2542 | auto inc = std::min(batch_size, num_remaining); |
| 2543 | to_tensor(i,i+inc,temp_tensor); |
| 2544 | subnetwork.forward(temp_tensor); |
| 2545 | const dimpl::subnet_wrapper<subnet_type> wsub(subnetwork); |
| 2546 | loss.to_label(temp_tensor, wsub, o, std::forward<T>(args)...); |
| 2547 | |
| 2548 | i += inc; |
| 2549 | o += inc; |
| 2550 | num_remaining -= inc; |
| 2551 | } |
| 2552 | return results; |
| 2553 | } |
| 2554 | |
| 2555 | void back_propagate_error( |
| 2556 | const tensor& x, |