-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathStandardUnit.cpp
More file actions
35 lines (31 loc) · 813 Bytes
/
StandardUnit.cpp
File metadata and controls
35 lines (31 loc) · 813 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
#include "StandardUnit.h"
#include "Layer.h"
#include <cstdio>
using namespace std;
StandardUnit::StandardUnit(){
passCount = -1;
}
float StandardUnit::getOutput(int pass){
if(pass==passCount)
return outputComputed;
passCount = pass;
float output = 0;
float weights2 = 0;
//printf("start %d %d %d\n",ly,lx,lz);
for(int i=0; i <iy;i++){
for(int j=0; j<ix;j++){
for(int k=0;k <iz;k++){
//printf("trying to get input\n");
Neuron* n = getInput(i,j,k);
//printf("got input %ld\n",n);
output+=n->getOutput(pass)*weights[i][j][k];
weights2+=weights[i][j][k]*weights[i][j][k];
//printf("%f ",n->getOutput(pass));
}
}
//printf("\n");
}
//printf("\n");
outputComputed = layer->activationFunction(output+*bias)+weights2*(layer->weightDecay)/2.0;
return outputComputed;
}