Documentation
¶
Index ¶
- func NewKaimingNormalInit(fanIn int) func() float64
- func NewXavierNormalInit(fanIn, fanOut int) func() float64
- func NewXavierUniformInit(fanIn, fanOut int) func() float64
- type AdamOptimizer
- type AddNode
- type ColSliceNode
- type ColSumNode
- type ConvNode
- type CrossEntropyLossNode
- type DivElementNode
- type DropoutNode
- type GradThresholdNode
- type HConcatNode
- type L2Normalizer
- type LogNode
- type MSELossNode
- type Matrix
- func (m *Matrix) Add(other *Matrix) (result *Matrix)
- func (m *Matrix) ColSlice(start, end int) *Matrix
- func (m *Matrix) ColSum() *Matrix
- func (m *Matrix) DivElement(other *Matrix) *Matrix
- func (m *Matrix) HConcat(other *Matrix) (result *Matrix)
- func (m *Matrix) Multi(other *Matrix) (result *Matrix)
- func (m *Matrix) MultiElement(other *Matrix) (result *Matrix)
- func (m *Matrix) Negate() (result *Matrix)
- func (m *Matrix) Reshape(rows, cols int) *Matrix
- func (m *Matrix) RowSlice(start, end int) *Matrix
- func (m *Matrix) RowSum() *Matrix
- func (m *Matrix) Scale(rate float64) *Matrix
- func (m *Matrix) String() string
- func (m *Matrix) Sub(other *Matrix) (result *Matrix)
- func (m *Matrix) Trans() (result *Matrix)
- func (m *Matrix) VConcat(other *Matrix) (result *Matrix)
- type MinMaxScaler
- type Model
- type MultiElementNode
- type MultiNode
- type NeuralNetwork
- type Node
- type Normalizer
- type Optimizer
- type PoolNode
- type ReLuNode
- type ReshapeNode
- type RobustScaler
- type RowSliceNode
- type RowSumNode
- type SGDOptimizer
- type ScaleNode
- type Scaler
- type SigmoidNode
- type SoftmaxNode
- type SubNode
- type TanhNode
- type TransNode
- type VConcatNode
- type ValueThresholdNode
- type VariableNode
- type ZScoreScaler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewKaimingNormalInit ¶
func NewXavierNormalInit ¶
func NewXavierUniformInit ¶
Types ¶
type AdamOptimizer ¶
type AdamOptimizer struct {
LearningRate float64
Beta1 float64
Beta2 float64
M []*Matrix
V []*Matrix
T int
Eps float64
Parameters []*VariableNode
}
func NewAdamOptimizer ¶
func NewAdamOptimizer(parameters []*VariableNode, learningRate, beta1, beta2, eps float64) *AdamOptimizer
func (*AdamOptimizer) Reset ¶
func (opt *AdamOptimizer) Reset()
func (*AdamOptimizer) Step ¶
func (opt *AdamOptimizer) Step(batchSize int)
type AddNode ¶
type AddNode struct {
X Node
Y Node
Value *Matrix
Name string
// contains filtered or unexported fields
}
AddNode defines a node that performs matrix addition operations.
type ColSliceNode ¶
type ColSliceNode struct {
X Node
Start, End int
Value *Matrix
Name string
// contains filtered or unexported fields
}
ColSliceNode defines a node that performs matrix slicing along the column direction.
func ColSlice ¶
func ColSlice(x Node, start, end int) *ColSliceNode
func (*ColSliceNode) Backward ¶
func (m *ColSliceNode) Backward(grad *Matrix)
func (*ColSliceNode) Forward ¶
func (m *ColSliceNode) Forward() *Matrix
func (*ColSliceNode) Reset ¶
func (m *ColSliceNode) Reset()
func (*ColSliceNode) Tag ¶
func (m *ColSliceNode) Tag(name string) Node
type ColSumNode ¶
type ColSumNode struct {
X Node
Value *Matrix
Name string
// contains filtered or unexported fields
}
func ColSum ¶
func ColSum(x Node) *ColSumNode
func (*ColSumNode) Backward ¶
func (m *ColSumNode) Backward(grad *Matrix)
func (*ColSumNode) Forward ¶
func (m *ColSumNode) Forward() *Matrix
func (*ColSumNode) Reset ¶
func (m *ColSumNode) Reset()
func (*ColSumNode) Tag ¶
func (m *ColSumNode) Tag(name string) Node
type ConvNode ¶
type CrossEntropyLossNode ¶
type CrossEntropyLossNode struct {
X Node
Y Node
Value *Matrix
Name string
// contains filtered or unexported fields
}
CrossEntropyLossNode defines a node dedicated to calculating cross entropy loss. It should be used in conjunction with the SoftmaxNode, meaning that the preceding node of this one should be a SoftmaxNode.
func CrossEntropyLoss ¶
func CrossEntropyLoss(x Node, y Node) *CrossEntropyLossNode
func (*CrossEntropyLossNode) Backward ¶
func (m *CrossEntropyLossNode) Backward(grad *Matrix)
func (*CrossEntropyLossNode) Forward ¶
func (m *CrossEntropyLossNode) Forward() *Matrix
func (*CrossEntropyLossNode) Reset ¶
func (m *CrossEntropyLossNode) Reset()
func (*CrossEntropyLossNode) Tag ¶
func (m *CrossEntropyLossNode) Tag(name string) Node
type DivElementNode ¶
type DivElementNode struct {
X Node
Y Node
Value *Matrix
Name string
// contains filtered or unexported fields
}
func Div ¶
func Div(x Node, y Node) *DivElementNode
func (*DivElementNode) Backward ¶
func (m *DivElementNode) Backward(grad *Matrix)
func (*DivElementNode) Forward ¶
func (m *DivElementNode) Forward() *Matrix
func (*DivElementNode) Reset ¶
func (m *DivElementNode) Reset()
func (*DivElementNode) Tag ¶
func (m *DivElementNode) Tag(name string) Node
type DropoutNode ¶
type DropoutNode struct {
X Node
P float64 //Keep probability
Value *Matrix
Name string
// contains filtered or unexported fields
}
DropoutNode defines a node that performs Dropout operations.
func Dropout ¶
func Dropout(x Node, p float64) *DropoutNode
func (*DropoutNode) Backward ¶
func (m *DropoutNode) Backward(grad *Matrix)
func (*DropoutNode) Forward ¶
func (m *DropoutNode) Forward() *Matrix
func (*DropoutNode) Reset ¶
func (m *DropoutNode) Reset()
func (*DropoutNode) Tag ¶
func (m *DropoutNode) Tag(name string) Node
type GradThresholdNode ¶
type GradThresholdNode struct {
X Node
Value *Matrix
Threshold float64
Name string
// contains filtered or unexported fields
}
GradThresholdNode defines a processing node that, during forward propagation, does not perform any processing and directly passes the input to the next step. In backpropagation, it controls whether to continue propagation based on the set Threshold. When the module of the gradient is less than the Threshold, backpropagation will stop.
func GradThreshold ¶
func GradThreshold(x Node, threshold float64) *GradThresholdNode
func (*GradThresholdNode) Backward ¶
func (m *GradThresholdNode) Backward(grad *Matrix)
func (*GradThresholdNode) Forward ¶
func (m *GradThresholdNode) Forward() *Matrix
func (*GradThresholdNode) Reset ¶
func (m *GradThresholdNode) Reset()
func (*GradThresholdNode) Tag ¶
func (m *GradThresholdNode) Tag(name string) Node
type HConcatNode ¶
type HConcatNode struct {
X Node
Y Node
Value *Matrix
Name string
// contains filtered or unexported fields
}
HConcatNode defines a node for matrix horizontal concatenation.
func HConcat ¶
func HConcat(x Node, y Node) *HConcatNode
func (*HConcatNode) Backward ¶
func (m *HConcatNode) Backward(grad *Matrix)
func (*HConcatNode) Forward ¶
func (m *HConcatNode) Forward() *Matrix
func (*HConcatNode) Reset ¶
func (m *HConcatNode) Reset()
func (*HConcatNode) Tag ¶
func (m *HConcatNode) Tag(name string) Node
type L2Normalizer ¶
func NewL2Normalizer ¶
func NewL2Normalizer(dim int, groups [][]int) *L2Normalizer
func (*L2Normalizer) Normalize ¶
func (n *L2Normalizer) Normalize(data [][]float64) [][]float64
type MSELossNode ¶
type MSELossNode struct {
X Node
Y Node
Value *Matrix
Name string
// contains filtered or unexported fields
}
MSELossNode defines a node for calculating mean square error loss.
func MSELoss ¶
func MSELoss(x Node, y Node) *MSELossNode
func (*MSELossNode) Backward ¶
func (m *MSELossNode) Backward(grad *Matrix)
func (*MSELossNode) Forward ¶
func (m *MSELossNode) Forward() *Matrix
func (*MSELossNode) Reset ¶
func (m *MSELossNode) Reset()
func (*MSELossNode) Tag ¶
func (m *MSELossNode) Tag(name string) Node
type Matrix ¶
func NewConstMatrix ¶
func NewRandomMatrix ¶
func (*Matrix) DivElement ¶
func (*Matrix) MultiElement ¶
type MinMaxScaler ¶
type MinMaxScaler struct {
Min []float64 `json:"min"`
Max []float64 `json:"max"`
Groups [][]int `json:"groups"`
Dim int `json:"dim"`
}
func NewMinMaxScaler ¶
func NewMinMaxScaler(dim int, groups [][]int) *MinMaxScaler
func (*MinMaxScaler) Fit ¶
func (m *MinMaxScaler) Fit(data [][]float64)
func (*MinMaxScaler) Transform ¶
func (m *MinMaxScaler) Transform(data [][]float64) [][]float64
type Model ¶
type Model struct {
Parameters []*VariableNode `json:"parameters"`
InputScalers []Scaler `json:"input_scalers"`
TargetScalers []Scaler `json:"target_scalers"`
}
func NewModel ¶
func NewModel(parameters []*VariableNode, inputScalers, targetScalers []Scaler) *Model
type MultiElementNode ¶
type MultiElementNode struct {
X Node
Y Node
Value *Matrix
Name string
// contains filtered or unexported fields
}
MultiElementNode defines a node that performs matrix multiplication based on the corresponding elements.
func MultiElement ¶
func MultiElement(x Node, y Node) *MultiElementNode
func (*MultiElementNode) Backward ¶
func (m *MultiElementNode) Backward(grad *Matrix)
func (*MultiElementNode) Forward ¶
func (m *MultiElementNode) Forward() *Matrix
func (*MultiElementNode) Reset ¶
func (m *MultiElementNode) Reset()
func (*MultiElementNode) Tag ¶
func (m *MultiElementNode) Tag(name string) Node
type MultiNode ¶
type MultiNode struct {
X Node
Y Node
Value *Matrix
Name string
// contains filtered or unexported fields
}
MultiNode defines a node that performs matrix multiplication operations.
type NeuralNetwork ¶
type NeuralNetwork struct {
// contains filtered or unexported fields
}
func NewNeuralNetwork ¶
func NewNeuralNetwork( buildFunc func() (input, target *VariableNode, output, loss Node), optimizer Optimizer) *NeuralNetwork
func (*NeuralNetwork) Evaluate ¶
func (nn *NeuralNetwork) Evaluate(inputData, targetData [][]float64) (lossValue float64, outputData [][]float64)
func (*NeuralNetwork) Predict ¶
func (nn *NeuralNetwork) Predict(inputData []float64) (outputData []float64)
type Normalizer ¶
type PoolNode ¶
type ReshapeNode ¶
type ReshapeNode struct {
X Node
Rows int
Cols int
Value *Matrix
Name string
// contains filtered or unexported fields
}
func Reshape ¶
func Reshape(x Node, rows, cols int) *ReshapeNode
func (*ReshapeNode) Backward ¶
func (m *ReshapeNode) Backward(grad *Matrix)
func (*ReshapeNode) Forward ¶
func (m *ReshapeNode) Forward() *Matrix
func (*ReshapeNode) Reset ¶
func (m *ReshapeNode) Reset()
func (*ReshapeNode) Tag ¶
func (m *ReshapeNode) Tag(name string) Node
type RobustScaler ¶
type RobustScaler struct {
Median []float64 `json:"median"`
IQR []float64 `json:"IQR"`
Groups [][]int `json:"groups"`
Dim int `json:"dim"`
}
func NewRobustScaler ¶
func NewRobustScaler(dim int, groups [][]int) *RobustScaler
func (*RobustScaler) Fit ¶
func (m *RobustScaler) Fit(data [][]float64)
func (*RobustScaler) Transform ¶
func (m *RobustScaler) Transform(data [][]float64) [][]float64
type RowSliceNode ¶
type RowSliceNode struct {
X Node
Start, End int
Value *Matrix
Name string
// contains filtered or unexported fields
}
RowSliceNode defines a node that performs matrix slicing along row direction.
func RowSlice ¶
func RowSlice(x Node, start, end int) *RowSliceNode
func (*RowSliceNode) Backward ¶
func (m *RowSliceNode) Backward(grad *Matrix)
func (*RowSliceNode) Forward ¶
func (m *RowSliceNode) Forward() *Matrix
func (*RowSliceNode) Reset ¶
func (m *RowSliceNode) Reset()
func (*RowSliceNode) Tag ¶
func (m *RowSliceNode) Tag(name string) Node
type RowSumNode ¶
type RowSumNode struct {
X Node
Value *Matrix
Name string
// contains filtered or unexported fields
}
func RowSum ¶
func RowSum(x Node) *RowSumNode
func (*RowSumNode) Backward ¶
func (m *RowSumNode) Backward(grad *Matrix)
func (*RowSumNode) Forward ¶
func (m *RowSumNode) Forward() *Matrix
func (*RowSumNode) Reset ¶
func (m *RowSumNode) Reset()
func (*RowSumNode) Tag ¶
func (m *RowSumNode) Tag(name string) Node
type SGDOptimizer ¶
type SGDOptimizer struct {
LearningRate float64
Momentum float64
Velocity []*Matrix
Parameters []*VariableNode
}
func NewSGDOptimizer ¶
func NewSGDOptimizer(parameters []*VariableNode, learningRate, momentum float64) *SGDOptimizer
func (*SGDOptimizer) Reset ¶
func (opt *SGDOptimizer) Reset()
func (*SGDOptimizer) Step ¶
func (opt *SGDOptimizer) Step(batchSize int)
type ScaleNode ¶
type SigmoidNode ¶
type SigmoidNode struct {
X Node
Value *Matrix
Name string
// contains filtered or unexported fields
}
SigmoidNode defines a node that executes Sigmoid activation function.
func Sigmoid ¶
func Sigmoid(x Node) *SigmoidNode
func (*SigmoidNode) Backward ¶
func (m *SigmoidNode) Backward(grad *Matrix)
func (*SigmoidNode) Forward ¶
func (m *SigmoidNode) Forward() *Matrix
func (*SigmoidNode) Reset ¶
func (m *SigmoidNode) Reset()
func (*SigmoidNode) Tag ¶
func (m *SigmoidNode) Tag(name string) Node
type SoftmaxNode ¶
type SoftmaxNode struct {
X Node
Value *Matrix
Name string
// contains filtered or unexported fields
}
SoftmaxNode defines a node that executes the Softmax activation function
func Softmax ¶
func Softmax(x Node) *SoftmaxNode
func (*SoftmaxNode) Backward ¶
func (m *SoftmaxNode) Backward(grad *Matrix)
func (*SoftmaxNode) Forward ¶
func (m *SoftmaxNode) Forward() *Matrix
func (*SoftmaxNode) Reset ¶
func (m *SoftmaxNode) Reset()
func (*SoftmaxNode) Tag ¶
func (m *SoftmaxNode) Tag(name string) Node
type SubNode ¶
type SubNode struct {
X Node
Y Node
Value *Matrix
Name string
// contains filtered or unexported fields
}
SubNode defines a node that performs matrix subtraction operations.
type TransNode ¶
type VConcatNode ¶
type VConcatNode struct {
X Node
Y Node
Value *Matrix
Name string
// contains filtered or unexported fields
}
VConcatNode defines a node for matrix vertical concatenation.
func VConcat ¶
func VConcat(x Node, y Node) *VConcatNode
func (*VConcatNode) Backward ¶
func (m *VConcatNode) Backward(grad *Matrix)
func (*VConcatNode) Forward ¶
func (m *VConcatNode) Forward() *Matrix
func (*VConcatNode) Reset ¶
func (m *VConcatNode) Reset()
func (*VConcatNode) Tag ¶
func (m *VConcatNode) Tag(name string) Node
type ValueThresholdNode ¶
type ValueThresholdNode struct {
X Node
Value *Matrix
MinValue float64
MaxValue float64
Name string
// contains filtered or unexported fields
}
func ValueThreshold ¶
func ValueThreshold(x Node, minVal, maxVal float64) *ValueThresholdNode
func (*ValueThresholdNode) Backward ¶
func (m *ValueThresholdNode) Backward(grad *Matrix)
func (*ValueThresholdNode) Forward ¶
func (m *ValueThresholdNode) Forward() *Matrix
func (*ValueThresholdNode) Reset ¶
func (m *ValueThresholdNode) Reset()
func (*ValueThresholdNode) Tag ¶
func (m *ValueThresholdNode) Tag(name string) Node
type VariableNode ¶
type VariableNode struct {
Name string `json:"name"`
Value *Matrix `json:"value"`
Gradient *Matrix `json:"-"`
// contains filtered or unexported fields
}
VariableNode defines a variable node.
func NewConstVariable ¶
func NewConstVariable(rows, cols int, value float64) *VariableNode
func NewRandomVariable ¶
func NewRandomVariable(rows, cols int, f func() float64) *VariableNode
func NewVariable ¶
func NewVariable(rows, cols int, data []float64) *VariableNode
func (*VariableNode) Backward ¶
func (v *VariableNode) Backward(grad *Matrix)
func (*VariableNode) Forward ¶
func (v *VariableNode) Forward() *Matrix
func (*VariableNode) Reset ¶
func (v *VariableNode) Reset()
func (*VariableNode) Tag ¶
func (v *VariableNode) Tag(name string) Node
type ZScoreScaler ¶
type ZScoreScaler struct {
Mean []float64 `json:"mean"`
StdDeviation []float64 `json:"stdDeviation"`
Groups [][]int `json:"groups"`
Dim int `json:"dim"`
}
func NewZScoreScaler ¶
func NewZScoreScaler(dim int, groups [][]int) *ZScoreScaler
func (*ZScoreScaler) Fit ¶
func (m *ZScoreScaler) Fit(data [][]float64)
func (*ZScoreScaler) Transform ¶
func (m *ZScoreScaler) Transform(data [][]float64) [][]float64