Documentation
¶
Overview ¶
Package util ...
Index ¶
- func AnnealingLearningRate(eta0, decay float64, epoch int) float64
- func GenInputsAndLabelsFromCorpus[T TokenType](corpus [][]T, vocab map[T]int, ctxLen int) ([][]int, []int)
- func GenVocabFromCorpus[T TokenType](corpus [][]T, eos T) map[T]int
- func GetIndexToToken[T TokenType](vocab map[T]int) []T
- func IndexesToTokens[T TokenType](indexes []int, i2t []T) []T
- func InteractiveTrain(cfg *TrainConfig, interactive bool, train func() time.Duration, predict func())
- func MaskedAttention[T any](ks, qs, vs [][]T, mul func([]T, []T) T, softmax func([]T) []T) (out []T)
- func Must1[T any](x T, err error) T
- func NumberSliceConvert[From, To constraints.Integer | constraints.Float](vs []From) []To
- func OneHot(index, vocabSize int) []float64
- func OneHots(indexes []int, vocabSize int) []float64
- func PredictionPrecision(p Predictor, testSet []Sample, isCorrect IsCorrectFunc) float32
- func RandMultinomial(probDist []float64) int
- func RandomUniformSample(min, max float64) float64
- func ReadCSVDataSet(file string) ([][]string, error)
- func ShuffleSamples[T any](samples []T)
- func SliceConvert[From, To any](s []From) []To
- func Softmax(t float64, xs []float64) []float64
- func SplitDataSet[T any](samples []T, trainSplit, valSplit float64) (training, validation, testing []T)
- func TokensToIndexes[T TokenType](tokens []T, vocab map[T]int) []int
- func Transpose[T any](mat [][]T) [][]T
- type IsCorrectFunc
- type LearningRateFunc
- type Optimizer
- type Parameter
- type Predictor
- type Sample
- type TokenType
- type TrainConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnnealingLearningRate ¶
AnnealingLearningRate returns an annealed learning rate by the following formula:
η = η_0 / (1 + decay * epoch)
func GenVocabFromCorpus ¶
func GetIndexToToken ¶
func IndexesToTokens ¶
func InteractiveTrain ¶
func InteractiveTrain(cfg *TrainConfig, interactive bool, train func() time.Duration, predict func())
func MaskedAttention ¶
func MaskedAttention[T any](ks, qs, vs [][]T, mul func([]T, []T) T, softmax func([]T) []T) (out []T)
func NumberSliceConvert ¶
func NumberSliceConvert[From, To constraints.Integer | constraints.Float](vs []From) []To
func PredictionPrecision ¶
func PredictionPrecision(p Predictor, testSet []Sample, isCorrect IsCorrectFunc) float32
func RandMultinomial ¶
func RandomUniformSample ¶
func ReadCSVDataSet ¶
func ShuffleSamples ¶
func ShuffleSamples[T any](samples []T)
func SliceConvert ¶
func SliceConvert[From, To any](s []From) []To
func SplitDataSet ¶
func TokensToIndexes ¶
Types ¶
type IsCorrectFunc ¶
type LearningRateFunc ¶
func AnnealingLearningRateFunc ¶
func AnnealingLearningRateFunc(eta, decay float64, epoch int) LearningRateFunc
type Optimizer ¶
type Optimizer interface {
Learn() float64
}
func AdamOptimizer ¶
func DefaultAdamOptimizer ¶
func SGDOptimizer ¶
type Sample ¶
Click to show internal directories.
Click to hide internal directories.