Documentation
¶
Index ¶
- func ApplyScaledDotProductAttention(queries [][]float64, keys [][]float64, values [][]float64, softmax [][]float64, ...) []float64
- func CalculateLossMatrix(predictedOutput [][]float64, targetOutput [][]float64) [][]float64
- func ClipMatByNorm(gradients [][]float64, maxNorm float64)
- func ClipVecByNorm(gradients []float64, maxNorm float64)
- func Forest(file string) error
- func NewRandomForest(size, features int) *ensemble.RandomForest
- func NormalizeMat(tensor [][]float64) [][]float64
- func NormalizeVec(tensor []float64) []float64
- func PreProcessAttributes(iris *base.DenseInstances) (*base.LazilyFilteredInstances, error)
- func RandomForestPredict(tree base.Classifier, fileName string, template *base.DenseInstances, ...) (base.FixedDataGrid, error)
- func RandomForestTrain(tree base.Classifier, fileName string, size, features int, debug bool) (base.Classifier, *base.DenseInstances, float64, error)
- func ResidualConnectionMat(input, output [][]float64) [][]float64
- func ResidualConnectionVec(input, output []float64) []float64
- type AttentionHead
- type Cluster
- type DecoderLayer
- type EncoderLayer
- type FeedForward
- type GRU
- type KMeans
- type Metadata
- type MultiHeadAttention
- type Transformer
- func (model *Transformer) BackProp(loss [][]float64, learningRate float64)
- func (model *Transformer) Decode(input [][]float64, encoderOutput [][]float64) [][]float64
- func (model *Transformer) Encode(input [][]float64) [][]float64
- func (model *Transformer) Forward(inputSequence [][]float64) [][]float64
- func (model *Transformer) Train(learningRate float64, epochs int, inputSequence [][]float64, ...)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyScaledDotProductAttention ¶
func ApplyScaledDotProductAttention(queries [][]float64, keys [][]float64, values [][]float64, softmax [][]float64, scale float64) []float64
ApplyScaledDotProductAttention computes the scaled dot-product attention given queries, keys, and values
func CalculateLossMatrix ¶
CalculateLossMatrix calculates the loss as a matrix given the predicted output and the target output
func ClipMatByNorm ¶
ClipMatByNorm clips gradients based on their global L2 norm.
func ClipVecByNorm ¶
ClipVecByNorm clips gradients based on their global L2 norm.
func NewRandomForest ¶
func NewRandomForest(size, features int) *ensemble.RandomForest
func NormalizeMat ¶
NormalizeMat normalizes the input tensor across the feature dimension
func NormalizeVec ¶
NormalizeVec normalizes the input tensor across the feature dimension
func PreProcessAttributes ¶
func PreProcessAttributes(iris *base.DenseInstances) (*base.LazilyFilteredInstances, error)
func RandomForestPredict ¶
func RandomForestPredict(tree base.Classifier, fileName string, template *base.DenseInstances, debug bool) (base.FixedDataGrid, error)
func RandomForestTrain ¶
func RandomForestTrain(tree base.Classifier, fileName string, size, features int, debug bool) (base.Classifier, *base.DenseInstances, float64, error)
func ResidualConnectionMat ¶
ResidualConnectionMat adds a residual connection between two tensors
func ResidualConnectionVec ¶
ResidualConnectionVec adds a residual connection between two tensors
Types ¶
type AttentionHead ¶
type AttentionHead struct {
// contains filtered or unexported fields
}
type DecoderLayer ¶
type DecoderLayer struct {
// contains filtered or unexported fields
}
type EncoderLayer ¶
type EncoderLayer struct {
// contains filtered or unexported fields
}
func (*EncoderLayer) Encode ¶
func (layer *EncoderLayer) Encode(input [][]float64) [][]float64
Encode applies the Transformer encoder layer to encode input sequences
type FeedForward ¶
type FeedForward struct {
// contains filtered or unexported fields
}
func NewFeedForward ¶
func NewFeedForward(meta meta, in, out int) *FeedForward
func (*FeedForward) BackProp ¶
func (ffn *FeedForward) BackProp(loss [][]float64, learningRate float64)
BackProp computes the gradients of the loss function and updates the parameters of the feedforward layer
func (*FeedForward) Decode ¶
func (ffn *FeedForward) Decode(inputSequence [][]float64) [][]float64
func (*FeedForward) Encode ¶
func (ffn *FeedForward) Encode(inputSequence [][]float64) [][]float64
type KMeans ¶
type KMeans struct {
// contains filtered or unexported fields
}
type Metadata ¶
type Metadata struct { Samples int Clusters map[int]Cluster Features []float64 Accuracy float64 Loss []float64 }
func NewMetadata ¶
func NewMetadata() Metadata
type MultiHeadAttention ¶
type MultiHeadAttention struct {
// contains filtered or unexported fields
}
func NewMultiHeadAttention ¶
func NewMultiHeadAttention(numHeads int, in, out int) *MultiHeadAttention
func (*MultiHeadAttention) BackProp ¶
func (attention *MultiHeadAttention) BackProp(loss [][]float64, learningRate float64)
BackProp computes the gradients of the loss function and updates the parameters of the multi-head attention mechanism
func (*MultiHeadAttention) Decode ¶
func (attention *MultiHeadAttention) Decode(input [][]float64, encoderOutput [][]float64) [][]float64
func (*MultiHeadAttention) Encode ¶
func (attention *MultiHeadAttention) Encode(input [][]float64) [][]float64
type Transformer ¶
type Transformer struct {
// contains filtered or unexported fields
}
func NewTransformer ¶
func NewTransformer(numHeads, numLayers int, dim ...int) *Transformer
func (*Transformer) BackProp ¶
func (model *Transformer) BackProp(loss [][]float64, learningRate float64)
BackProp function for backpropagation
func (*Transformer) Decode ¶
func (model *Transformer) Decode(input [][]float64, encoderOutput [][]float64) [][]float64
func (*Transformer) Encode ¶
func (model *Transformer) Encode(input [][]float64) [][]float64
func (*Transformer) Forward ¶
func (model *Transformer) Forward(inputSequence [][]float64) [][]float64