-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from cshenton/xnes
options, examples
- Loading branch information
Showing
10 changed files
with
144 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package opt | ||
|
||
// Options is a configuration struct which can holds options commond to several of | ||
// the optimisers in the package. | ||
type Options struct { | ||
Adaptive bool // Whether to use an adaptive learning rate, if available | ||
GenerationSize uint // Number of score evaluations per gradient update | ||
LearningRate float64 // The learning rate | ||
RandomSeed uint64 // Used to seed the source used to generate seeds for searches | ||
} | ||
|
||
// DefaultOptions is the recommended set of initial options for most optimisers. | ||
var DefaultOptions = &Options{ | ||
Adaptive: true, | ||
GenerationSize: 10, | ||
LearningRate: 0.01, | ||
RandomSeed: 24601, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package opt |