This commit is contained in:
2026-04-28 23:23:57 +07:00
parent ced1c1c291
commit 229c5d85c4
4 changed files with 158 additions and 16 deletions
+34 -8
View File
@@ -1,13 +1,39 @@
#include <iostream>
int calculate(int a, int b) {
return a + o;
}
#include <vector>
#include <ctime>
#include "Xenith/core.h"
#include "Xenith/typedef.h"
int main() {
// print hello world and test void calculate function
std::cout << "Hello World!" << std::endl;
int result = calculate(1, 2);
std::cout << result << std::endl;
srand(time(NULL));
LayerStructure_t layers[] = {
{2, SIGMOID}, // Вход: 2 числа
{3, SIGMOID}, // Скрытый слой
{1, SIGMOID} // Выход: 1 число
};
NeuralNetwork nn(layers, 3);
// Данные для обучения
std::vector<std::vector<double>> inputs = {{1, 1}, {1, 0}, {0, 0}, {0, 1}};
std::vector<std::vector<double>> targets = {{0}, {1}, {1}, {0}};
// Цикл обучения
std::cout << "Training..." << std::endl;
for (int epoch = 0; epoch < 20000; epoch++) {
for (int i = 0; i < inputs.size(); i++) {
nn.train(inputs[i], targets[i], 0.5);
}
}
// Проверка результатов
std::cout << "Results:" << std::endl;
for (int i = 0; i < inputs.size(); i++) {
std::vector<double> res = nn.feedForward(inputs[i]);
std::cout << inputs[i][0] << " " << inputs[i][1] << " -> "
<< (res[0] > 0.5 ? 1 : 0) << " (raw: " << res[0] << ")" << std::endl;
}
return 0;
}