29inline double Sigmoid(
double x) {
return 1.0 / (1.0 + std::exp(-x)); }
41 throw std::invalid_argument(
"FixedTopologyXORForward: theta must have exactly kFixedTopologyXORNumParams entries");
43 double h0 =
detail::Sigmoid(theta[0] * inputs[0] + theta[1] * inputs[1] + theta[2]);
44 double h1 =
detail::Sigmoid(theta[3] * inputs[0] + theta[4] * inputs[1] + theta[5]);
55 static const std::array<std::array<double, 2>, 4> kInputs{
56 {{0.0, 0.0}, {0.0, 1.0}, {1.0, 0.0}, {1.0, 1.0}}};
57 static const std::array<double, 4> kExpected{0.0, 1.0, 1.0, 0.0};
59 double sum_squared_error = 0.0;
60 for (
size_t i = 0; i < kInputs.size(); ++i) {
62 double error = kExpected[i] - actual;
63 sum_squared_error += error * error;
65 return 4.0 - sum_squared_error;
double Sigmoid(double x)
Definition fixed_topology_xor_network.hpp:29
Definition acquisition_functions.hpp:16
double FixedTopologyXORFitness(const std::vector< double > &theta)
Scores theta against all four XOR patterns as 4.0 minus the sum of squared errors – identical convent...
Definition fixed_topology_xor_network.hpp:54
double FixedTopologyXORForward(const std::vector< double > &theta, const std::array< double, 2 > &inputs)
Forward pass: theta layout is [w1_00, w1_01, b1_0, w1_10, w1_11, b1_1, w2_0, w2_1,...
Definition fixed_topology_xor_network.hpp:39
constexpr size_t kFixedTopologyXORNumParams
Total flat-parameter count: 2*2 (input->hidden weights) + 2 (hidden biases) + 2 (hidden->output weigh...
Definition fixed_topology_xor_network.hpp:26
@ Sigmoid
1 / (1 + exp(-x))