| 53 | } |
| 54 | |
| 55 | void benchmark_perceptron(const array &train_feats, const array &train_targets, |
| 56 | const array test_feats) { |
| 57 | timer::start(); |
| 58 | array Weights = train(train_feats, train_targets, 0.1, 0.01, 1000); |
| 59 | af::sync(); |
| 60 | printf("Training time: %4.4lf s\n", timer::stop()); |
| 61 | |
| 62 | timer::start(); |
| 63 | const int iter = 100; |
| 64 | for (int i = 0; i < iter; i++) { |
| 65 | array test_outputs = predict(test_feats, Weights); |
| 66 | test_outputs.eval(); |
| 67 | } |
| 68 | af::sync(); |
| 69 | printf("Prediction time: %4.4lf s\n", timer::stop() / iter); |
| 70 | } |
| 71 | |
| 72 | // Demo of one vs all logistic regression |
| 73 | int perceptron_demo(bool console, int perc) { |
no test coverage detected