-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathInputLayer.cpp
More file actions
65 lines (50 loc) · 1.51 KB
/
InputLayer.cpp
File metadata and controls
65 lines (50 loc) · 1.51 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "InputLayer.h"
#include "InputUnit.h"
#include "activationFunctions.h"
#include <algorithm>
#include <cassert>
#include <cstdio>
using namespace std;
Neuron**** InputLayer::initNeuronArray(int width, int height, int channels){
Neuron**** array = new Neuron*** [height];
for(int i =0; i<height;i++){
array[i] = new Neuron** [width];
for(int j = 0; j < width; j++){
array[i][j] = new Neuron*[channels];
for(int k=0; k < channels; k++){
InputUnit *iu = new InputUnit();
array[i][j][k]=iu;
iu->layer = this;
iu->lx=j;
iu->ly=i;
iu->lz=k;
}
}
}
return array;
}
Neuron* InputLayer::getInput(int, int, int, int, int, int){
fprintf(stderr,"Trying to get input neuron from input neruon");
assert(false);
return NULL;
}
void InputLayer::setInputValue(int x, int y, int z, float value){
InputUnit* n = dynamic_cast<InputUnit*>(neurons[y][x][z]);
n->setInputValue(value);
}
float InputLayer::getInputValue(int x, int y, int z){
InputUnit* n = dynamic_cast<InputUnit*>(neurons[y][x][z]);
return n->getInputValue();
}
void InputLayer::backProp(int){}
void InputLayer::updateWeights(int){}
float InputLayer::getLamdba(){return epsilon*weightDecay;}
InputLayer::InputLayer(int width,int height, int channels){
this->width = width;
this->height = height;
this->depth = channels;
this->activationGradient = ActivationFunctions::noGradient;
this->activationFunction = ActivationFunctions::noGradient;
neurons = initNeuronArray(width,height, channels);
printf("created input layer\n");
}