-
Notifications
You must be signed in to change notification settings - Fork 1
/
dcautoregular.go
150 lines (133 loc) · 3.8 KB
/
dcautoregular.go
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package dcnetworks
import (
gocunets "github.com/dereklstinson/gocunets"
"github.com/dereklstinson/gocunets/devices/gpu/nvidia/cudnn"
"github.com/dereklstinson/gocunets/layers/activation"
"github.com/dereklstinson/gocunets/layers/cnn"
"github.com/dereklstinson/gocunets/trainer"
"github.com/dereklstinson/gocunets/utils"
gocudnn "github.com/dereklstinson/gocudnn"
)
//DcAutoNoConvTrans using regular method of increasing size of convolution...by just increasing the outer padding
func DcAutoNoConvTrans(handle *cudnn.Handler,
frmt gocudnn.TensorFormat,
dtype gocudnn.DataType,
CMode gocudnn.ConvolutionMode,
memmanaged bool,
batchsize int32) *gocunets.Network {
filter := utils.Dims
padding := utils.Dims
stride := utils.Dims
dilation := utils.Dims
//var tmdf gocudnn.TrainingModeFlag
//tmode := tmdf.Adam()
//var aflg gocudnn.ActivationModeFlag
network := gocunets.CreateNetwork()
//Setting Up Network
/*
Convoultion Layer E1 1
*/
const numofneurons = int32(50)
network.AddLayer(
cnn.Setup(handle, frmt, dtype, filter(numofneurons, 1, 8, 8), CMode, padding(0, 0), stride(1, 1), dilation(1, 1), 200),
) //28-8+1 = 21
/*
Activation Layer E2 2
*/
network.AddLayer(
activation.Leaky(handle),
)
/*
Convoultion Layer E3 3
*/
network.AddLayer(
cnn.Setup(handle, frmt, dtype, filter(numofneurons, numofneurons, 8, 8), CMode, padding(0, 0), stride(1, 1), dilation(1, 1), 234),
) //21-8+1 =14
/*
Activation Layer E4 4
*/
network.AddLayer(
activation.Leaky(handle),
)
/*
Convoultion Layer E5 5
*/
network.AddLayer(
cnn.Setup(handle, frmt, dtype, filter(numofneurons, numofneurons, 8, 8), CMode, padding(0, 0), stride(1, 1), dilation(1, 1), 1),
) // 14-8+1=7
/*
Activation Layer E6 6
*/
network.AddLayer(
activation.Leaky(handle),
)
/*
Convoultion Layer E7 7
*/
network.AddLayer(
cnn.Setup(handle, frmt, dtype, filter(4, numofneurons, 7, 7), CMode, padding(0, 0), stride(1, 1), dilation(1, 1), 5),
) // 1
/*
Activation Layer MIDDLE 8
*/
network.AddLayer(
activation.Leaky(handle),
)
/*
Convoultion Layer D1 9
*/
network.AddLayer(
cnn.Setup(handle, frmt, dtype, filter(numofneurons, 4, 7, 7), CMode, padding(6, 6), stride(1, 1), dilation(1, 1), 6),
) //7
/*
Activation Layer D2 10
*/
network.AddLayer(
activation.Leaky(handle),
)
/*
Convoultion Layer D3 11
*/
network.AddLayer(
cnn.Setup(handle, frmt, dtype, filter(numofneurons, numofneurons, 8, 8), CMode, padding(7, 7), stride(1, 1), dilation(1, 1), 9),
) //7-8+(14)+1 =14
/*
Activation Layer D4 12
*/
network.AddLayer(
activation.Leaky(handle),
)
/*
Convoultion Layer D5 13
*/
network.AddLayer(
cnn.Setup(handle, frmt, dtype, filter(numofneurons, numofneurons, 8, 8), CMode, padding(7, 7), stride(1, 1), dilation(1, 1), 150),
) //14-8 +14 +1 =21
/*
Activation Layer D6 14
*/
network.AddLayer(
activation.Leaky(handle),
)
/*
Convoultion Layer D7 15
*/
network.AddLayer(
cnn.Setup(handle, frmt, dtype, filter(1, numofneurons, 8, 8), CMode, padding(7, 7), stride(1, 1), dilation(1, 1), 13),
) //28
//var err error
numoftrainers := network.TrainersNeeded()
trainersbatch := make([]trainer.Trainer, numoftrainers) //If these were returned then you can do some training parameter adjustements on the fly
trainerbias := make([]trainer.Trainer, numoftrainers) //If these were returned then you can do some training parameter adjustements on the fly
for i := 0; i < numoftrainers; i++ {
a, b, err := trainer.SetupAdamWandB(handle.XHandle(), .00001, .00001, batchsize)
a.SetRates(.001, .001)
b.SetRates(.001, .001)
trainersbatch[i], trainerbias[i] = a, b
if err != nil {
panic(err)
}
}
network.LoadTrainers(handle, trainersbatch, trainerbias) //Load the trainers in the order they are needed
return network
}