| 5 | #include "Network.h" |
| 6 | |
| 7 | Network::Network(std::vector<int> neurons, double learningRate) { |
| 8 | srand(time(NULL)); |
| 9 | |
| 10 | this->learningRate = learningRate; |
| 11 | this->hiddenLayersCount = neurons.size() - 2; |
| 12 | |
| 13 | H = std::vector<Matrix<double> >(hiddenLayersCount + 2); |
| 14 | W = std::vector<Matrix<double> >(hiddenLayersCount + 1); |
| 15 | B = std::vector<Matrix<double> >(hiddenLayersCount + 1); |
| 16 | dEdW = std::vector<Matrix<double> >(hiddenLayersCount + 1); |
| 17 | dEdB = std::vector<Matrix<double> >(hiddenLayersCount + 1); |
| 18 | |
| 19 | for (int i = 0; i < neurons.size() - 1; i++) { |
| 20 | W[i] = Matrix<double>(neurons[i], neurons[i + 1]); |
| 21 | B[i] = Matrix<double>(1, neurons[i + 1]); |
| 22 | |
| 23 | W[i] = W[i].applyFunction(random); |
| 24 | B[i] = B[i].applyFunction(random); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | Network::Network(const char *filepath) { |
| 29 | loadNetworkParams(filepath); |
nothing calls this directly
no test coverage detected