Documentation
¶
Index ¶
- Constants
- Variables
- func LinearRegression(x, y Matrix) (b0, b1 float64)
- func MetaGMM(input Matrix, clusters int) []int
- func SelfEntropy(Q, K, V Matrix) []float32
- func SelfEntropy64(Q, K, V Matrix) []float64
- type ComplexMatrix
- type CompressedGenerator
- type CompressedRandomMatrix
- type GMM
- type Generator
- type Matrix
- func (m Matrix) Add(n Matrix) Matrix
- func (m Matrix) Avg() Matrix
- func (m Matrix) Determinant() (float64, error)
- func (m Matrix) Everett() Matrix
- func (m Matrix) H(n Matrix) Matrix
- func (m Matrix) Inverse(rng *Rand) (ai Matrix)
- func (m Matrix) LU() (Matrix, Matrix)
- func (m Matrix) Mul(n Matrix) Matrix
- func (m Matrix) MulT(n Matrix) Matrix
- func (m Matrix) Normalize() Matrix
- func (m Matrix) Quadratic(n Matrix) Matrix
- func (m Matrix) QuadraticSet(n Matrix, set []int) Matrix
- func (m Matrix) Sigmoid() Matrix
- func (m Matrix) Size() int
- func (m Matrix) Slice(begin, end int) Matrix
- func (m Matrix) Step() Matrix
- func (m Matrix) String() string
- func (m Matrix) Sub(n Matrix) Matrix
- func (m Matrix) T() Matrix
- func (m Matrix) TaylorSoftmax() Matrix
- type Multi
- type Net
- type Optimizer
- type Rand
- type Random
- type RandomMatrix
- type Sample
Constants ¶
const ( // S is the scaling factor for the softmax S = 1.0 - 1e-300 // LFSRMask is a LFSR mask with a maximum period LFSRMask = 0x80000057 )
Variables ¶
var Iris = [150][5]float32{}/* 150 elements not displayed */
Iris is the iris dataset
var IrisNames = map[float32]string{
0: "Iris-setosa",
1: "Iris-versicolor",
2: "Iris-virginica",
}
IrisNames is the names of the flowers
Functions ¶
func LinearRegression ¶
LinearRegression computes linear regression https://www.geeksforgeeks.org/linear-regression-python-implementation/
func SelfEntropy ¶
SelfEntropy computes the self entropy of Q, K, V
func SelfEntropy64 ¶
SelfEntropy64 computes the self entropy of Q, K, V
Types ¶
type ComplexMatrix ¶
type ComplexMatrix struct {
Cols int
Rows int
Data []complex128
}
ComplexMatrix is a complex128 matrix
func ComplexSelfAttention ¶
func ComplexSelfAttention(Q, K, V ComplexMatrix) ComplexMatrix
ComplexSelfAttention computes the self attention of Q, K, V
func NewComplexMatrix ¶
func NewComplexMatrix(cols, rows int, data ...complex128) ComplexMatrix
NewComplexMatrix creates a new complex128 matrix
type CompressedGenerator ¶
type CompressedGenerator struct {
Distribution CompressedRandomMatrix
Seed uint32
}
CompressedGenerator generates a matrix by sampling from a probability distribution
func (CompressedGenerator) Sample ¶
func (g CompressedGenerator) Sample() Matrix
Sample samples a matrix
func (CompressedGenerator) Sparse ¶
func (g CompressedGenerator) Sparse() Matrix
Sample samples a matrix
func (CompressedGenerator) Uniform ¶
func (g CompressedGenerator) Uniform() Matrix
Sample samples a matrix
type CompressedRandomMatrix ¶
CompressedRandomMatrix is a compressed random matrix
func NewCompressedRandomMatrix ¶
func NewCompressedRandomMatrix(cols, rows int) CompressedRandomMatrix
NewCompressedRandomMatrix returns a new compressed random matrix
func (CompressedRandomMatrix) Sample ¶
func (r CompressedRandomMatrix) Sample(rng *Rand) CompressedGenerator
Sample samples a matrix
func (CompressedRandomMatrix) SampleDiscrete ¶
func (r CompressedRandomMatrix) SampleDiscrete(rng *Rand) Matrix
SampleDiscrete generates a discrete matrix sample
type GMM ¶
GMMO is an optimizer based gmm
func NewGMM ¶
NewGMM creates a new optimizer based gmm https://github.com/Ransaka/GMM-from-scratch https://en.wikipedia.org/wiki/Multivariate_normal_distribution
type Generator ¶
type Generator struct {
Distribution RandomMatrix
Seed uint32
}
Generator generates a matrix by sampling from a probability distribution
type Matrix ¶
Matrix is a float32 matrix
func NewIdentityMatrix ¶
NewIdentityMatrix creates a new float32 identity matrix of zeros
func NewZeroMatrix ¶
NewZeroMatrix creates a new float32 matrix of zeros
func SelfAttention ¶
SelfAttention computes the self attention of Q, K, V
func (Matrix) Determinant ¶
Determinant calculates the determinant of a matrix
func (Matrix) LU ¶
LU lower upper decomposition https://www.geeksforgeeks.org/doolittle-algorithm-lu-decomposition/
func (Matrix) QuadraticSet ¶
QuadraticSet computes the quadratic loss of sub sets of two matrices
func (Matrix) TaylorSoftmax ¶
TaylorSoftmax is the taylor softmax https://arxiv.org/abs/1511.05042
type Multi ¶
Multi is a multivariate distribution
func NewMultiFromData ¶
NewMultiFromData creates a new multivariate distribution
type Optimizer ¶
type Optimizer struct {
N int
Length int
Scale float64
Rng *Rand
Vars [][3]RandomMatrix
Cost func(samples []Sample, a ...Matrix)
Reg bool
Norm bool
}
Optimizer is an optimizer
type Rand ¶
type Rand uint32
Rand is a random number generator
func (*Rand) NormFloat64 ¶
NormFloat64 returns a normally distributed float64 in the range -math.MaxFloat64 through +[math.MaxFloat64] inclusive, with standard normal distribution (mean = 0, stddev = 1). To produce a different normal distribution, callers can adjust the output using:
sample = NormFloat64() * desiredStdDev + desiredMean
type RandomMatrix ¶
RandomMatrix is a random matrix
func NewRandomMatrix ¶
func NewRandomMatrix(cols, rows int) RandomMatrix
NewRandomMatrix returns a new random matrix
func (RandomMatrix) Sample ¶
func (r RandomMatrix) Sample(rng *Rand) Generator
Sample samples a matrix
func (RandomMatrix) SampleDiscrete ¶
func (r RandomMatrix) SampleDiscrete(rng *Rand) Matrix
SampleDiscrete generates a discrete matrix sample