ditto
auto xt = tensor!([0, 2])([[0.1, 0.9], [0.8, 0.2], [0.4, 0.6], [0.2, 0.8]]); auto y0 = tensor!([0, 2])([[1.0, 0.0], [0.0, 1.0], [1.0, 0.0], [1.0, 0.0]]); // true: 0 auto y1 = tensor!([0, 2])([[1.0, 0.0], [0.0, 1.0], [1.0, 0.0], [0.0, 1.0]]); // true: 1 auto y2 = tensor!([0, 2])([[1.0, 0.0], [0.0, 1.0], [0.0, 1.0], [0.0, 1.0]]); // true: 2 auto y3 = tensor!([0, 2])([[1.0, 0.0], [1.0, 0.0], [0.0, 1.0], [0.0, 1.0]]); // true: 3 auto y4 = tensor!([0, 2])([[0.0, 1.0], [1.0, 0.0], [0.0, 1.0], [0.0, 1.0]]); // true: 4 assert(accuracy(xt, y0) == 0.0f); assert(accuracy(xt, y1) == 0.25f); assert(accuracy(xt, y2) == 0.5f); assert(accuracy(xt, y3) == 0.75f); assert(accuracy(xt, y4) == 1.0f);
calc accuracy for multi class (multiple 0-1 output)