forked from damianmarzec/Jarvis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNeuron.cpp
More file actions
48 lines (34 loc) · 845 Bytes
/
Neuron.cpp
File metadata and controls
48 lines (34 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "stdafx.h"
#include "Neuron.h"
#include <iostream>
#include <cstdlib>
Neuron::Neuron(unsigned outputsCount, unsigned myIndex)
{
std::cout << "Neuron creating..." << std::endl;
for (unsigned c = 0; c < outputsCount; ++c) {
outputWeights.push_back(Connection());
}
index = myIndex;
}
void Neuron::setOutputValue(double input)
{
outputVal = input;
}
double Neuron::getOutputValue() const
{
return outputVal;
}
void Neuron::feedForward(const Layer &prevLayer)
{
double sum = 0.0;
// dodajemy wszystkie wejœcia
// pamiêtaæ o neuroenie bias z poprzedniej warstwy
for (unsigned neuronNr = 0; neuronNr < prevLayer.size(); ++neuronNr) {
sum += prevLayer[neuronNr].getOutputVal() * prevLayer[neuronNr].outputWeights[index].weight;
}
// todo
}
double Neuron::randomWeight(void)
{
return rand() / double(RAND_MAX);
}