// Get accuracy of the predicted results float accuracy(const array& predicted, const array& target) { return 100 * count<float>(predicted == target) / target.elements(); }
float abserr(const array& predicted, const array& target) { return 100 * sum<float>(abs(predicted - target)) / predicted.elements(); }
#include <arrayfire.h> #include <af/dim4.hpp> #include <string> #include <vector> #include <testHelpers.hpp> using std::vector; using af::array; using af::randu; TEST(rgb_gray, 32bit) { array rgb = randu(10, 10, 3); array gray = rgb2gray(rgb); vector<float> h_rgb(rgb.elements()); vector<float> h_gray(gray.elements()); rgb.host(&h_rgb[0]); gray.host(&h_gray[0]); int num = gray.elements(); int roff = 0; int goff = num; int boff = 2 * num; const float rPercent=0.2126f; const float gPercent=0.7152f; const float bPercent=0.0722f; for (int i = 0; i < num; i++) {