-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathLInput.h
79 lines (45 loc) · 1.61 KB
/
LInput.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
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef INPUTLAYER_H
#define INPUTLAYER_H
#include "Layer.h"
class LInput : public Layer {
public:
//Constructor
LInput( int out_dim, int in_rows, int in_cols ) {
//Set dimensions
this->in_rows = in_rows;
this->in_cols = in_cols;
this->in_dim = out_dim; //This could be different! See feedforward()!
this->out_rows = in_rows;
this->out_cols = in_cols;
this->out_dim = out_dim; //Number of feature maps
in.resize(in_dim, in_rows, in_cols);
out.resize(out_dim, out_rows, out_cols);
}
//Properties
char getType() { return 'i'; }
//Functions
Tensor feedforward( Tensor in ) {
if (in.getDim() < in_dim) { //Need to artifically increase input dimensions to match feature map dimensions
for (int d = 0; d < in_dim; d++) {
for (int i = 0; i < in_rows; i++) {
for (int j = 0; j < in_cols; j++) {
if (d < in.getDim()) { //Within bounds
this->in(d, i, j) = in(d, i, j);
} else { //Out of bounds: copy first dimension into this one.
this->in(d, i, j) = in(0, i, j);
}
}
}
}
this->out = this->in.copy();
return out;
} else { //Input dimensions are greater or equal to the feature map dimensions
this->in = in.copy();
this->out = in.copy();
return out;
}
}
Tensor feedback( Tensor delta ) { return NULL; }
void updateweights( float rate ) { return; }
};
#endif