28 lines
866 B
C++
28 lines
866 B
C++
#ifndef CORE_H
|
|
#define CORE_H
|
|
|
|
#include "typedef.h"
|
|
#include <vector>
|
|
#include <cmath>
|
|
#include <iostream>
|
|
#include <cstdlib>
|
|
|
|
class NeuralNetwork {
|
|
private:
|
|
int numLayers;
|
|
std::vector<int> layerSizes;
|
|
std::vector<std::vector<std::vector<double>>> weights; // weights[layer][to_node][from_node]
|
|
std::vector<std::vector<double>> biases; // biases[layer][node]
|
|
std::vector<std::vector<double>> outputs; // Храним выходы слоев для backprop
|
|
|
|
double sigmoid(double x) { return 1.0 / (1.0 + exp(-x)); }
|
|
double sigmoidDerivative(double x) { return x * (1.0 - x); }
|
|
|
|
public:
|
|
NeuralNetwork(LayerStructure_t layers[], int count);
|
|
|
|
std::vector<double> feedForward(std::vector<double> input);
|
|
void train(std::vector<double> input, std::vector<double> target, double learningRate);
|
|
};
|
|
|
|
#endif |