Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion training/model.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
package training

import "math/rand"
import (
"math/rand"
"sync"
)

// Example is an input-target pair
type Example struct {
Input []float64
Response []float64
}

var mu sync.Mutex

// Examples is a set of input-output pairs
type Examples []Example

// Shuffle shuffles slice in-place
func (e Examples) Shuffle() {
for i := range e {
mu.Lock()
j := rand.Intn(i + 1)
e[i], e[j] = e[j], e[i]
mu.Unlock()
}
}

Expand Down