SNABSuite  0.x
Spiking Neural Architecture Benchmark Suite
Static Public Member Functions | List of all members
MNIST::MSE Class Reference

Root Mean Squared Error. More...

#include <mnist_mlp.hpp>

Static Public Member Functions

static Real calc_loss (const uint16_t label, const std::vector< Real > &output)
 
static std::vector< Real > calc_error (const uint16_t label, const std::vector< Real > &output)
 

Detailed Description

Root Mean Squared Error.

Definition at line 34 of file mnist_mlp.hpp.

Member Function Documentation

static std::vector<Real> MNIST::MSE::calc_error ( const uint16_t  label,
const std::vector< Real > &  output 
)
inlinestatic

Definition at line 51 of file mnist_mlp.hpp.

53  {
54  std::vector<Real> res(output.size(), 0.0);
55  for (size_t neuron = 0; neuron < output.size(); neuron++) {
56  if (label == neuron) {
57  res[neuron] = output[neuron] - 1.0;
58  }
59  else {
60  res[neuron] = output[neuron] - 0.0;
61  }
62  }
63  return res;
64  }
static Real MNIST::MSE::calc_loss ( const uint16_t  label,
const std::vector< Real > &  output 
)
inlinestatic

Definition at line 36 of file mnist_mlp.hpp.

38  {
39  Real res = 0.0;
40  for (size_t neuron = 0; neuron < output.size(); neuron++) {
41  if (label == neuron) {
42  res += (output[neuron] - 1.0) * (output[neuron] - 1.0);
43  }
44  else {
45  res += output[neuron] * output[neuron];
46  }
47  }
48  res = sqrt(res / Real(output.size()));
49  return res;
50  }

The documentation for this class was generated from the following file: