forked from btgraham/SparseConvNet-archived
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetworkArchitectures.cpp
More file actions
68 lines (63 loc) · 2.72 KB
/
NetworkArchitectures.cpp
File metadata and controls
68 lines (63 loc) · 2.72 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
66
67
68
#include "NetworkArchitectures.h"
DeepCNet::DeepCNet (int dimension, int l, int k, ActivationFunction fn, int nInputFeatures, int nClasses, float p, int nTop) : SparseConvNet(dimension,nInputFeatures, nClasses, nTop) {
for (int i=0;i<=l;i++)
addLeNetLayerMP((i+1)*k,
(i==0)?3:2,
1,
(i<l)?3:1,
(i<l)?2:1,
fn,
p*i*1.0f/l);
addSoftmaxLayer();
}
DeepC2::DeepC2 (int dimension, int l, int k, ActivationFunction fn, int nInputFeatures, int nClasses, float p, int nTop) : SparseConvNet(dimension,nInputFeatures, nClasses, nTop) {
for (int i=0;i<=l;i++)
addLeNetLayerMP((i+1)*k,
2,
1,
(i<l)?3:1,
(i<l)?2:1,
fn,
p*i*1.0f/l);
addSoftmaxLayer();
}
DeepCNiN::DeepCNiN (int dimension, int l, int k, ActivationFunction fn, int nInputFeatures, int nClasses, float p, int nTop) : SparseConvNet(dimension,nInputFeatures, nClasses, nTop) {
for (int i=0;i<=l;i++) {
addLeNetLayerMP((i+1)*k,
(i==0)?2:2,
1,
(i<l)?3:1,
(i<l)?2:1,
fn,
p*i*1.0f/l);
addLeNetLayerMP(1,1,1,1,(i+1)*k,fn,p*i*1.0f/l);
}
addSoftmaxLayer();
}
DeepC2C2::DeepC2C2(int dimension, int l, int k, ActivationFunction fn, int nInputFeatures, int nClasses, float p, int nTop) : SparseConvNet(dimension,nInputFeatures, nClasses, nTop) {
for (int i=0;i<l;i++) {
addLeNetLayerMP((i+1)*k,2,1,1,1,fn,p*i*1.0f/l);
addLeNetLayerMP((i+1)*k,2,1,3,2,fn,p*i*1.0f/l);
}
addLeNetLayerMP((l+1)*k,2,1,1,1,fn,p);
addLeNetLayerMP((l+1)*k,1,1,1,1,fn,p);
addSoftmaxLayer();
}
POFMPSparseConvNet::POFMPSparseConvNet(int dimension, int l, int k, float fmpShrink, ActivationFunction fn, int nInputFeatures, int nClasses, float p, int nTop) : SparseConvNet(dimension,nInputFeatures, nClasses, nTop) {
for (int i=0;i<l;i++) {
addLeNetLayerPOFMP(k*(i+1),2,1,2,fmpShrink,fn,p*i/(l+2));
}
addLeNetLayerPOFMP(k*(l+1),2,1,2,1.5,fn,p*l/(l+2));
addLeNetLayerMP(k*(l+2),2,1,1,1,fn,p*(l+1)/(l+2));
addLeNetLayerMP(k*(l+3),1,1,1,1,fn,p);
addSoftmaxLayer();
}
ROFMPSparseConvNet::ROFMPSparseConvNet(int dimension, int l, int k, float fmpShrink, ActivationFunction fn, int nInputFeatures, int nClasses, float p, int nTop) : SparseConvNet(dimension,nInputFeatures, nClasses, nTop) {
for (int i=0;i<l;i++) {
addLeNetLayerROFMP(k*(i+1),2,1,2,fmpShrink,fn,p*i/(l+2));
}
addLeNetLayerROFMP(k*(l+1),2,1,2,1.5,fn,p*l/(l+2));
addLeNetLayerMP(k*(l+2),2,1,1,1,fn,p*(l+1)/(l+2));
addLeNetLayerMP(k*(l+3),1,1,1,1,fn,p);
addSoftmaxLayer();
}