MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / benchmark_perceptron

Function benchmark_perceptron

examples/machine_learning/perceptron.cpp:55–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55void 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
73int perceptron_demo(bool console, int perc) {

Callers 1

perceptron_demoFunction · 0.85

Calls 4

trainFunction · 0.70
predictFunction · 0.70
syncFunction · 0.50
evalMethod · 0.45

Tested by

no test coverage detected