| 522 | |
| 523 | template <typename T> |
| 524 | float compare_gradients ( |
| 525 | const tensor& t, |
| 526 | T grad |
| 527 | ) |
| 528 | { |
| 529 | float max_error = 0; |
| 530 | auto p = t.host(); |
| 531 | for (size_t i = 0; i < t.size(); ++i) |
| 532 | { |
| 533 | max_error = std::max(max_error, std::abs(p[i]-grad(i))); |
| 534 | } |
| 535 | return max_error; |
| 536 | } |
| 537 | |
| 538 | // ---------------------------------------------------------------------------------------- |
| 539 |
no test coverage detected