refactor: add type parameter to layer inputs
This commit is contained in:
+9
-9
@@ -7,7 +7,7 @@
|
||||
static std::uniform_real_distribution<> dist(-1, 1);
|
||||
|
||||
int main(void) {
|
||||
static constexpr double s_trainData[4] = {
|
||||
static constexpr float s_trainData[4] = {
|
||||
0, // 0 ^ 0
|
||||
1, // 1 ^ 0
|
||||
1, // 0 ^ 1
|
||||
@@ -36,9 +36,9 @@ int main(void) {
|
||||
|
||||
while (gen <= 10'000'000) {
|
||||
for (std::size_t i = 0; i < 4; ++i) {
|
||||
cenet::mat<1, 2> xs;
|
||||
xs[0][0] = static_cast<double>(i & 1);
|
||||
xs[0][1] = static_cast<double>(i > 1);
|
||||
cenet::mat<1, 2, float> xs;
|
||||
xs[0][0] = static_cast<float>(i & 1);
|
||||
xs[0][1] = static_cast<float>(i > 1);
|
||||
|
||||
xorNet.train(xs, s_trainData[i], EPSILON);
|
||||
}
|
||||
@@ -46,12 +46,12 @@ int main(void) {
|
||||
double acc = 0.0;
|
||||
|
||||
for (std::size_t i = 0; i < 4; ++i) {
|
||||
cenet::mat<1, 2> xs;
|
||||
xs[0][0] = static_cast<double>(i & 1);
|
||||
xs[0][1] = static_cast<double>(i > 1);
|
||||
cenet::mat<1, 2, float> xs;
|
||||
xs[0][0] = static_cast<float>(i & 1);
|
||||
xs[0][1] = static_cast<float>(i > 1);
|
||||
|
||||
double yHat = xorNet.feed(xs).get()[0][0];
|
||||
double error = yHat - s_trainData[i];
|
||||
float yHat = xorNet.feed(xs).get()[0][0];
|
||||
float error = yHat - s_trainData[i];
|
||||
|
||||
if ((gen % 1000) == 0) {
|
||||
std::cout << xs[0][0] << " ^ " << xs[0][1] << " = " << yHat << " (error = " << error << ")\n";
|
||||
|
||||
Reference in New Issue
Block a user