matrix

package
v0.0.0-...-5f2bfed Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StateM is the state for the mean
	StateM = iota
	// StateV is the state for the variance
	StateV
	// StateTotal is the total number of states
	StateTotal
)
View Source
const (
	// S is the scaling factor for the softmax
	S = 1.0 - 1e-300
)

Variables

This section is empty.

Functions

func Determinant

func Determinant(a Matrix) (float32, error)

func InBetween

func InBetween(i, min, max int) bool

Types

type Mat

type Mat [][]float64

func (Mat) Columns

func (m Mat) Columns() int

func (Mat) Det

func (m Mat) Det() (float64, error)

func (Mat) ExcludeColumn

func (m Mat) ExcludeColumn(column int) (Mat, error)

func (Mat) ExcludeRow

func (m Mat) ExcludeRow(row int) (Mat, error)

func (Mat) IsMatrix

func (m Mat) IsMatrix() bool

func (Mat) IsSquare

func (m Mat) IsSquare() bool

func (Mat) Print

func (m Mat) Print()

func (Mat) Rows

func (m Mat) Rows() int

func (Mat) SubMatrix

func (m Mat) SubMatrix(column_start int, column_end int, row_start int, row_end int) (Mat, error)

type Matrix

type Matrix struct {
	Cols   int
	Rows   int
	Data   []float32
	States [][]float32
}

Matrix is a float32 matrix

func Add

func Add(m Matrix, n Matrix) Matrix

Add adds two float32 matrices

func EverettActivation

func EverettActivation(m Matrix) Matrix

EverettActivation is the everett complex activation function

func MulT

func MulT(m Matrix, n Matrix) Matrix

MulT multiplies two matrices and computes the transpose

func NewMatrix

func NewMatrix(states, cols, rows int) Matrix

NewMatrix32 creates a new float32 matrix

func Normalize

func Normalize(m Matrix) Matrix

Normalize normalizes a matrix to the unit vector

func SelfAttention

func SelfAttention(Q, K, V Matrix) Matrix

SelfAttention computes the self attention of Q, K, V

func SelfEntropy

func SelfEntropy(Q, K, V Matrix) ([]Matrix, []float32)

SelfEntropy computes the self entropy of Q, K, V

func Sigmoid

func Sigmoid(m Matrix) Matrix

Sigmoid computes the sigmoid of a matrix

func Step

func Step(m Matrix) Matrix

Step computes the step function of a float32 matrix

func Sub

func Sub(m Matrix, n Matrix) Matrix

Sub subtracts two float32 matrices

func T

func T(m Matrix) Matrix

T tramsposes a matrix

func TaylorSoftmax

func TaylorSoftmax(m Matrix) Matrix

TaylorSoftmax is the taylor softmax https://arxiv.org/abs/1511.05042

func (Matrix) Size

func (m Matrix) Size() int

Size is the size of the float32 matrix

type Multi

type Multi struct {
	A Matrix
	U []float32
}

Multi is a multivariate distribution

func Factor

func Factor(vars [][]float32, debug bool) Multi

Factor factores a matrix into AA^T

func NewMulti

func NewMulti(vars int) Multi

NewMulti make a new multi

func (Multi) Sample

func (m Multi) Sample(rng *rand.Rand) []float32

Sample samples from the multivariate distribution

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL