Documentation ¶
Index ¶
- func Get[T any](conn Conn[T]) T
- func GetGrad[T any](conn Conn[T]) T
- func NewMatAllocatorLike(m *mat.Dense) *matAllocator
- func NewVecAllocator(n int) *vecAllocator
- func NewVecAllocatorLike(v *mat.VecDense) *vecAllocator
- func Set[T any](conn Conn[T], val T)
- func SetGrad[T any](conn Conn[T], val T)
- type Allocator
- type BinaryNode
- func MatAddElem(g *Graph, inEpA Conn[*mat.Dense], inEpB Conn[*mat.Dense]) *BinaryNode[*mat.Dense, *mat.Dense, *mat.Dense]
- func MatMulElem(g *Graph, inEpA Conn[*mat.Dense], inEpB Conn[*mat.Dense]) *BinaryNode[*mat.Dense, *mat.Dense, *mat.Dense]
- func MatMulVec(g *Graph, inEpA Conn[*mat.Dense], inEpB Conn[*mat.VecDense]) *BinaryNode[*mat.Dense, *mat.VecDense, *mat.VecDense]
- func NewBinaryNode[T, U, V any](g *Graph, viV Allocator[V], op BinaryOp[T, U, V], aEp Conn[T], bEp Conn[U]) *BinaryNode[T, U, V]
- func NumAdd[T Num](g *Graph, inEpA Conn[T], inEpB Conn[T]) *BinaryNode[T, T, T]
- func NumMul[T Num](g *Graph, inEpA Conn[T], inEpB Conn[T]) *BinaryNode[T, T, T]
- func VecAddElem(g *Graph, inEpA Conn[*mat.VecDense], inEpB Conn[*mat.VecDense]) *BinaryNode[*mat.VecDense, *mat.VecDense, *mat.VecDense]
- func VecMulElem(g *Graph, inEpA Conn[*mat.VecDense], inEpB Conn[*mat.VecDense]) *BinaryNode[*mat.VecDense, *mat.VecDense, *mat.VecDense]
- type BinaryOp
- type Conn
- type Graph
- type Node
- type Num
- type UnaryNode
- func MatCosElem(g *Graph, inEp Conn[*mat.Dense]) *UnaryNode[*mat.Dense, *mat.Dense]
- func MatExpElem(g *Graph, inEp Conn[*mat.Dense]) *UnaryNode[*mat.Dense, *mat.Dense]
- func MatSinElem(g *Graph, inEp Conn[*mat.Dense]) *UnaryNode[*mat.Dense, *mat.Dense]
- func NewUnaryNode[T, U any](g *Graph, alloc Allocator[U], op UnaryOp[T, U], inEp Conn[T]) *UnaryNode[T, U]
- func NumCos[T Num](g *Graph, inEp Conn[T]) *UnaryNode[T, T]
- func NumExp[T Num](g *Graph, inEp Conn[T]) *UnaryNode[T, T]
- func NumSin[T Num](g *Graph, inEp Conn[T]) *UnaryNode[T, T]
- func VecCosElem(g *Graph, inEp Conn[*mat.VecDense]) *UnaryNode[*mat.VecDense, *mat.VecDense]
- func VecExpElem(g *Graph, inEp Conn[*mat.VecDense]) *UnaryNode[*mat.VecDense, *mat.VecDense]
- func VecSinElem(g *Graph, inEp Conn[*mat.VecDense]) *UnaryNode[*mat.VecDense, *mat.VecDense]
- type UnaryOp
- type ValueNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMatAllocatorLike ¶
NewMatAllocatorLike creates a new Allocator which actos on matricies of the same shape as m
func NewVecAllocator ¶
func NewVecAllocator(n int) *vecAllocator
func NewVecAllocatorLike ¶
NewVecAllocatorLike creates a new Allocator which actos on vectors of the same length as v
Types ¶
type Allocator ¶
type Allocator[T any] interface { // Create a new pointer to the data type New() *T // Set the data type to its zero value Zero(*T) // Check if the provided pointer to a data type is valid for this allocator. // For example, if we are allocating vecotrs, we will check if the provided vector has the same length as the vectors the allocator creates. Allowed(*T) error }
An allocator is a utility class used to manipulate the buffers for operations to act on. Each node has a unique allocator for every buffer that it creates. A value allocator can contain data about the buffer to allocate, for example how long the vectors that it allocates should be.
type BinaryNode ¶
type BinaryNode[T, U, V any] struct { // contains filtered or unexported fields }
func MatAddElem ¶
func MatAddElem(g *Graph, inEpA Conn[*mat.Dense], inEpB Conn[*mat.Dense]) *BinaryNode[*mat.Dense, *mat.Dense, *mat.Dense]
MatAddElem creates a node that performs an element-wise add operation
func MatMulElem ¶
func NewBinaryNode ¶
func VecAddElem ¶
func VecMulElem ¶
func (*BinaryNode[T, U, V]) Backward ¶
func (n *BinaryNode[T, U, V]) Backward()
func (*BinaryNode[T, U, V]) C ¶
func (n *BinaryNode[T, U, V]) C() (val, grad *V, allowed func(*V) error)
func (*BinaryNode[T, U, V]) Forward ¶
func (n *BinaryNode[T, U, V]) Forward()
func (*BinaryNode[T, U, V]) ZeroGrad ¶
func (n *BinaryNode[T, U, V]) ZeroGrad()
type BinaryOp ¶
type BinaryOp[T, U, V any] interface { ComputeForward(aVal *T, bVal *U, resVal *V) ComputeGrad(aVal, aGrad *T, bVal, bGrad *U, resVal, resGrad *V) }
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
func (*Graph) AllBackward ¶
func (g *Graph) AllBackward()
func (*Graph) AllForward ¶
func (g *Graph) AllForward()
func (*Graph) AllZeroGrads ¶
func (g *Graph) AllZeroGrads()
type UnaryNode ¶
type UnaryNode[T, U any] struct { // contains filtered or unexported fields }
func MatCosElem ¶
MatCosElem creates a node that performs an element-wise cos operation
func MatExpElem ¶
MatExpElem creates a node that performs an element-wise e^x operation
func MatSinElem ¶
MatSinElem creates a node that performs an element-wise sin operation
func NewUnaryNode ¶
func VecCosElem ¶
VecCosElem creates a node that performs an element-wise cos operation
func VecExpElem ¶
VecExpElem creates a node that performs an element-wise e^x operation
func VecSinElem ¶
VecSinElem creates a node that performs an element-wise sin operation
type UnaryOp ¶
type UnaryOp[T, U any] interface { ComputeForward(inVal *T, resVal *U) ComputeGrad(inVal, inGrad *T, resVal, resGrad *U) }
type ValueNode ¶
type ValueNode[T any] struct { // contains filtered or unexported fields }
func NumValue ¶
*************************************************** Inputs ***************************************************