tc128

package
v0.0.0-...-e3d2a19 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: BSD-3-Clause Imports: 7 Imported by: 12

Documentation

Index

Constants

View Source
const LFSRMask = 0x80000057

LFSRMask is a LFSR mask with a maximum period

Variables

View Source
var (
	// Static is the static context
	Static Context
	// Op is a operation
	Op = Static.Op
	// B converts a binary function into an operator
	B = Static.B
	// U converts a unary function into an operator
	U = Static.U
	// Copy copies src tensors into dst
	Copy = B(Static.Copy)
	// Add adds two tensors
	Add = B(Static.Add)
	// Sub subtracts two tensors
	Sub = B(Static.Sub)
	// Mul multiplies two tensors
	Mul = B(Static.Mul)
	// Hadamard computes the hadamard product of two tensors
	Hadamard = B(Static.Hadamard)
	// T the transpose of the matrix
	T = U(Static.T)

	// H the conjugate transpose of the matrix
	H = U(Static.H)

	// Slice slices the matrix
	Slice = U(Static.Slice)
	// Concat concats two tensors
	Concat = B(Static.Concat)
	// Dropout is a dropout regularization function
	Dropout = U(Static.Dropout)
	// Sin the sin of a tensors
	Sin = U(Static.Sin)
	// Cos the cosine of a tensor
	Cos = U(Static.Cos)
	// Exp the base e exponential of a tensor
	Exp = U(Static.Exp)
	// Log the natural logarithm of a tensor
	Log = U(Static.Log)
	// Sigmoid the sigmoid of a tensors
	Sigmoid = U(Static.Sigmoid)
	// TanH the hyperbolic tangent of a tensor
	TanH = U(Static.TanH)
	// Softplus the softplus activation function
	Softplus = U(Static.Softplus)
	// Everett computes the split reality activation function
	Everett = U(Static.Everett)

	// Softmax is the softmax function
	Softmax = U(Static.Softmax)
	// Sum sums a vector
	Sum = U(Static.Sum)
	// SumRows sums the rows of the matrix
	SumRows = U(Static.SumRows)
	// Quadratic computes the quadratic cost of two tensors
	Quadratic = B(Static.Quadratic)
	// CrossEntropy computes the cross entropy cost of two tensors
	CrossEntropy = B(Static.CrossEntropy)
	// Similarity computes the cosine similarity cost of two tensors
	Similarity = B(Static.Similarity)
	// Orthogonality computes the cosine similarity between all vectros
	Orthogonality = U(Static.Orthogonality)
	// Entropy computes the entropy of the vectors
	Entropy = U(Static.Entropy)
	// Variance computes the variance of the vectors
	Variance = U(Static.Variance)
	// Abs computes the absolute value of the tensor
	Abs = U(Static.Abs)

	// Avg computes the average of the tensor
	Avg = U(Static.Avg)

	// Combines two complex tensors to a complex tensor
	Complex = B(Static.Complex)
	// Phase computes the phase of a complex tensor
	Phase = U(Static.Phase)
)

Functions

func Panic

func Panic(a *V) bool

Panic marks a place we should never get to

Types

type Binary

type Binary func(k Continuation, node int, a, b *V, options ...map[string]interface{}) bool

Binary is a binary function

type Context

type Context struct {
	Quantize uint
	Node     int
	Cache    map[int][]complex128
}

Context is a function context

func (*Context) Abs

func (context *Context) Abs(k Continuation, node int, a *V, options ...map[string]interface{}) bool

Abs computes the absolute value of the tensor

func (*Context) Add

func (context *Context) Add(k Continuation, node int, a, b *V, options ...map[string]interface{}) bool

Add adds two tensors

func (*Context) Avg

func (context *Context) Avg(k Continuation, node int, a *V, options ...map[string]interface{}) bool

Avg computes the average of the tensor

func (*Context) B

func (context *Context) B(op Binary) func(a, b Meta, options ...map[string]interface{}) Meta

B converts a binary function into an operator

func (*Context) Clear

func (c *Context) Clear()

Clear clears the cache

func (*Context) Complex

func (context *Context) Complex(k Continuation, node int, a, b *V, options ...map[string]interface{}) bool

Combines two complex tensors to a complex tensor

func (*Context) Concat

func (context *Context) Concat(k Continuation, node int, a, b *V, options ...map[string]interface{}) bool

Concat concats two tensors

func (*Context) Copy

func (context *Context) Copy(k Continuation, node int, dst, src *V, options ...map[string]interface{}) bool

Copy copies src tensors into dst

func (*Context) Cos

func (context *Context) Cos(k Continuation, node int, a *V, options ...map[string]interface{}) bool

Cos the cosine of a tensor

func (*Context) CrossEntropy

func (context *Context) CrossEntropy(k Continuation, node int, a, b *V, options ...map[string]interface{}) bool

CrossEntropy computes the cross entropy cost of two tensors

func (*Context) Dropout

func (context *Context) Dropout(k Continuation, node int, a *V, options ...map[string]interface{}) bool

Dropout is a dropout regularization function

func (*Context) Entropy

func (context *Context) Entropy(k Continuation, node int, a *V, options ...map[string]interface{}) bool

Entropy computes the entropy of the vectors

func (*Context) Everett

func (context *Context) Everett(k Continuation, node int, a *V, options ...map[string]interface{}) bool

Everett computes the split reality activation function

func (*Context) Exp

func (context *Context) Exp(k Continuation, node int, a *V, options ...map[string]interface{}) bool

Exp the base e exponential of a tensor

func (*Context) Get

func (c *Context) Get(node int) []complex128

Get gets a value from the cache

func (*Context) H

func (context *Context) H(k Continuation, node int, a *V, options ...map[string]interface{}) bool

H the conjugate transpose of the matrix

func (*Context) Hadamard

func (context *Context) Hadamard(k Continuation, node int, a, b *V, options ...map[string]interface{}) bool

Hadamard computes the hadamard product of two tensors

func (*Context) Log

func (context *Context) Log(k Continuation, node int, a *V, options ...map[string]interface{}) bool

Log the natural logarithm of a tensor

func (*Context) Mul

func (context *Context) Mul(k Continuation, node int, a, b *V, options ...map[string]interface{}) bool

Mul multiplies two tensors

func (*Context) Op

func (context *Context) Op(op Operation) func(a ...Meta) Meta

Op is a operation

func (*Context) Orthogonality

func (context *Context) Orthogonality(k Continuation, node int, a *V, options ...map[string]interface{}) bool

Orthogonality computes the cosine similarity between all vectros

func (*Context) Phase

func (context *Context) Phase(k Continuation, node int, a *V, options ...map[string]interface{}) bool

Phase computes the phase of a complex tensor

func (*Context) Quadratic

func (context *Context) Quadratic(k Continuation, node int, a, b *V, options ...map[string]interface{}) bool

Quadratic computes the quadratic cost of two tensors

func (*Context) Set

func (c *Context) Set(node int, value []complex128)

Set sets a value in the cache

func (*Context) Sigmoid

func (context *Context) Sigmoid(k Continuation, node int, a *V, options ...map[string]interface{}) bool

Sigmoid computes the sigmoid of a vector

func (*Context) Similarity

func (context *Context) Similarity(k Continuation, node int, a, b *V, options ...map[string]interface{}) bool

Similarity computes the cosine similarity cost of two tensors

func (*Context) Sin

func (context *Context) Sin(k Continuation, node int, a *V, options ...map[string]interface{}) bool

Sin the sine of a number

func (*Context) Slice

func (context *Context) Slice(k Continuation, node int, a *V, options ...map[string]interface{}) bool

Slice a slice of the matrix

func (*Context) Softmax

func (context *Context) Softmax(k Continuation, node int, a *V, options ...map[string]interface{}) bool

Softmax is the softmax function

func (*Context) Softplus

func (context *Context) Softplus(k Continuation, node int, a *V, options ...map[string]interface{}) bool

Softplus the softplus activation function

func (*Context) Sub

func (context *Context) Sub(k Continuation, node int, a, b *V, options ...map[string]interface{}) bool

Sub subtracts two tensors

func (*Context) Sum

func (context *Context) Sum(k Continuation, node int, a *V, options ...map[string]interface{}) bool

Sum sums a vector

func (*Context) SumRows

func (context *Context) SumRows(k Continuation, node int, a *V, options ...map[string]interface{}) bool

SumRows sums the rows of the matrix

func (*Context) T

func (context *Context) T(k Continuation, node int, a *V, options ...map[string]interface{}) bool

T the transpose of the matrix

func (*Context) TanH

func (context *Context) TanH(k Continuation, node int, a *V, options ...map[string]interface{}) bool

TanH the hyperbolic tangent of a tensor

func (*Context) U

func (context *Context) U(op Unary) func(a Meta, options ...map[string]interface{}) Meta

U converts a unary function into an operator

func (*Context) Variance

func (context *Context) Variance(k Continuation, node int, a *V, options ...map[string]interface{}) bool

Variance computes the variance of the vectors

type Continuation

type Continuation func(a *V) bool

Continuation is a continuation

type Meta

type Meta func(k Continuation) Continuation

Meta is a function that takes a continuation and return a continuation

type Operation

type Operation func(k Continuation, node int, a ...*V) bool

Operation is an operation that takes multiple parameters

type RNG

type RNG uint32

RNG is a random number generator

func (*RNG) Next

func (r *RNG) Next() uint32

Next returns the next random number

type Set

type Set struct {
	Weights []*V
	ByName  map[string]*V
}

Set is a set of V

func NewSet

func NewSet() Set

NewSet creates a new weight set

func (*Set) Add

func (s *Set) Add(name string, d ...int)

Add adds weights to a set

func (*Set) Copy

func (s *Set) Copy() Set

Copy generates a copy of a set

func (*Set) Get

func (s *Set) Get(name string) Meta

Get gets weights from the set by name

func (*Set) Open

func (s *Set) Open(name string) (complex128, int, error)

Open opens a set of weights

func (*Set) Save

func (s *Set) Save(file string, cost complex128, epoch int) error

func (*Set) Zero

func (s *Set) Zero()

Zero zeros the partial derivatives

type Unary

type Unary func(k Continuation, node int, a *V, options ...map[string]interface{}) bool

Unary is a unary function

type V

type V struct {
	N      string // the name
	Seed   RNG
	Drop   float64
	X      []complex128 // the tensor
	D      []complex128 // the derivative
	S      []int        // the shape
	States [][]complex128
}

V is a tensor value

func Gradient

func Gradient(a Meta) (cost V)

Gradient computes the gradient

func Identity

func Identity(s ...int) V

NewV create a new identity tensor value

func NewV

func NewV(s ...int) V

NewV create a new tensor value

func (*V) Copy

func (a *V) Copy() V

Copy copies the weights of the value

func (*V) Meta

func (a *V) Meta() Meta

Meta returns a meta for the value

func (*V) Set

func (a *V) Set(values []complex128)

Set sets the values and zeros the partial derivatives

func (*V) Zero

func (a *V) Zero()

Zero zeros the partial derivatives

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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