-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathAlphaDropout.go
executable file
·124 lines (105 loc) · 2.57 KB
/
AlphaDropout.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
package layer
import tf "github.com/galeone/tensorflow/tensorflow/go"
type LAlphaDropout struct {
dtype DataType
inputs []Layer
name string
noiseShape interface{}
rate float64
seed interface{}
shape tf.Shape
trainable bool
layerWeights []*tf.Tensor
}
func AlphaDropout(rate float64) *LAlphaDropout {
return &LAlphaDropout{
dtype: Float32,
name: UniqueName("alpha_dropout"),
noiseShape: nil,
rate: rate,
seed: nil,
trainable: true,
}
}
func (l *LAlphaDropout) SetDtype(dtype DataType) *LAlphaDropout {
l.dtype = dtype
return l
}
func (l *LAlphaDropout) SetName(name string) *LAlphaDropout {
l.name = name
return l
}
func (l *LAlphaDropout) SetNoiseShape(noiseShape interface{}) *LAlphaDropout {
l.noiseShape = noiseShape
return l
}
func (l *LAlphaDropout) SetSeed(seed interface{}) *LAlphaDropout {
l.seed = seed
return l
}
func (l *LAlphaDropout) SetShape(shape tf.Shape) *LAlphaDropout {
l.shape = shape
return l
}
func (l *LAlphaDropout) SetTrainable(trainable bool) *LAlphaDropout {
l.trainable = trainable
return l
}
func (l *LAlphaDropout) SetLayerWeights(layerWeights []*tf.Tensor) *LAlphaDropout {
l.layerWeights = layerWeights
return l
}
func (l *LAlphaDropout) GetShape() tf.Shape {
return l.shape
}
func (l *LAlphaDropout) GetDtype() DataType {
return l.dtype
}
func (l *LAlphaDropout) SetInputs(inputs ...Layer) Layer {
l.inputs = inputs
return l
}
func (l *LAlphaDropout) GetInputs() []Layer {
return l.inputs
}
func (l *LAlphaDropout) GetName() string {
return l.name
}
func (l *LAlphaDropout) GetLayerWeights() []*tf.Tensor {
return l.layerWeights
}
type jsonConfigLAlphaDropout struct {
ClassName string `json:"class_name"`
Name string `json:"name"`
Config map[string]interface{} `json:"config"`
InboundNodes [][][]interface{} `json:"inbound_nodes"`
}
func (l *LAlphaDropout) GetKerasLayerConfig() interface{} {
inboundNodes := [][][]interface{}{
{},
}
for _, input := range l.inputs {
inboundNodes[0] = append(inboundNodes[0], []interface{}{
input.GetName(),
0,
0,
map[string]bool{},
})
}
return jsonConfigLAlphaDropout{
ClassName: "AlphaDropout",
Name: l.name,
Config: map[string]interface{}{
"dtype": l.dtype.String(),
"name": l.name,
"noise_shape": l.noiseShape,
"rate": l.rate,
"seed": l.seed,
"trainable": l.trainable,
},
InboundNodes: inboundNodes,
}
}
func (l *LAlphaDropout) GetCustomLayerDefinition() string {
return ``
}