-
Notifications
You must be signed in to change notification settings - Fork 0
/
xnes.go
64 lines (52 loc) · 1.34 KB
/
xnes.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
package opt
import (
"sync"
"golang.org/x/exp/rand"
)
// XNES is the Exponential Natural Evolution Strategies optimiser. It is an NES optimiser
// that uses a multinormal search distribution, taking advantage of a closed form computation
// of the fisher information matrix.
type XNES struct {
// Generation data
size uint
searchCount uint
showCount uint
scores []float64
seeds []int64
// Search distribution parameters
len uint
loc []float64
scale float64
shape []float64
// Search hyperparameters
rate float64
adaptive bool
// Noise source
source *rand.Rand
// Mutex
*sync.Mutex
}
// NewXNES creates an XNES optimiser over the d-dimensional real numbers, using the provided
// options for the optimiser.
// func NewXNES(d uint, o *Options) (s *SNES) {
// scale := make([]float64, d)
// for i := range scale {
// scale[i] = initScale
// }
// s = &SNES{
// size: o.GenerationSize,
// showCount: 0,
// searchCount: 0,
// scores: make([]float64, o.GenerationSize),
// seeds: make([]int64, o.GenerationSize),
// len: d,
// loc: make([]float64, d),
// scale: scale,
// //shape: IDENTITY MATRIX
// rate: o.LearningRate,
// adaptive: o.Adaptive,
// source: rand.New(rand.NewSource(uint64(o.RandomSeed))),
// Mutex: &sync.Mutex{},
// }
// return s
// }