-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNeuron.h
37 lines (26 loc) · 941 Bytes
/
Neuron.h
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
#pragma once
#ifndef NEURON_H
#define NEURON_H
#include <vector>
#include <random>
#include <ctime>
#include "ActivationFunction.h"
class Neuron {
private:
std::vector<double> weights;
double bias;
ActivationFunction* activationFunction;
double xavRand(int inputs, int outputs); //uses Xavier initialization method to determine the range of random weights
public:
Neuron(int numInputs, int numOutputs, ActivationFunction* activationFunction);
double dotProduct(const std::vector<double>& a, const std::vector<double>& b); //computes the dot product of two vectors
double feedForward(const std::vector<double>& inputs);
double activate(double x);
std::vector<double> getWeights() const;
double getWeightAtIndex(int index) const;
double getBias() const;
void setWeights(const std::vector<double>& newWeights);
void setWeightAtIndex(int index, double newWeight);
void setBias(double newBias);
};
#endif // !NEURON_H