-
Notifications
You must be signed in to change notification settings - Fork 24
/
params_test.go
76 lines (65 loc) · 1.6 KB
/
params_test.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
// Copyright (c) 2019, The Emergent Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package params
import (
"testing"
"github.com/stretchr/testify/assert"
)
type test struct {
Name string
Class string
Norm bool
Momentum bool
WtBal bool
WtScale float32
}
func (t *test) StyleName() string { return t.Name }
func (t *test) StyleClass() string { return t.Class }
var paramSets = Sheets[*test]{
"Base": {
{Sel: "", Doc: "norm and momentum on works better, but wt bal is not better for smaller nets",
Set: func(t *test) {
t.Norm = true
t.Momentum = true
t.WtBal = false
}},
{Sel: ".Back", Doc: "top-down back-pathways MUST have lower relative weight scale, otherwise network hallucinates",
Set: func(t *test) {
t.WtScale = 0.2
}},
{Sel: "#ToOutput", Doc: "to output must be stronger",
Set: func(t *test) {
t.WtScale = 2.0
}},
},
"NoMomentum": {
{Sel: "", Doc: "no norm or momentum",
Set: func(t *test) {
t.Norm = false
t.Momentum = false
}},
},
"WtBalOn": {
{Sel: "", Doc: "weight bal on",
Set: func(t *test) {
t.WtBal = true
}},
},
}
func TestSet(t *testing.T) {
tf := &test{}
tf.Name = "Forward"
tb := &test{}
tb.Class = "Back"
to := &test{}
to.Name = "ToOutput"
paramSets["Base"].Apply(tf)
assert.Equal(t, true, tf.Norm)
paramSets["Base"].Apply(tb)
assert.Equal(t, float32(0.2), tb.WtScale)
paramSets["Base"].Apply(to)
assert.Equal(t, float32(2.0), to.WtScale)
paramSets["NoMomentum"].Apply(tf)
assert.Equal(t, false, tf.Norm)
}