ml

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logistic

func Logistic(x, a float64) float64

func Normal

func Normal(stdDev, mean float64) float64

func Uniform

func Uniform(stdDev, mean float64) float64

Types

type ActivationType

type ActivationType int
const (
	ActivationNone ActivationType = iota
	ActivationSigmoid
	ActivationTanh
	ActivationReLU
	ActivationLinear
	ActivationSoftmax
)

func OutputActivation

func OutputActivation(c Mode) ActivationType

type BinaryCrossEntropy

type BinaryCrossEntropy struct{}

func (BinaryCrossEntropy) Df

func (l BinaryCrossEntropy) Df(estimate, ideal, activation float64) float64

func (BinaryCrossEntropy) F

func (l BinaryCrossEntropy) F(estimate, ideal [][]float64) float64

type Config

type Config struct {
	Inputs     int
	Layout     []int
	Activation ActivationType
	Mode       Mode
	Weight     WeightInitializer `json:"-"`
	Loss       LossType
	Bias       bool
}

type CrossEntropy

type CrossEntropy struct{}

func (CrossEntropy) Df

func (l CrossEntropy) Df(estimate, ideal, activation float64) float64

func (CrossEntropy) F

func (l CrossEntropy) F(estimate, ideal [][]float64) float64

type Differentiable

type Differentiable interface {
	F(float64) float64
	Df(float64) float64
}

func GetActivation

func GetActivation(act ActivationType) Differentiable

type Dump

type Dump struct {
	Config  *Config
	Weights [][][]float64
}

type Layer

type Layer struct {
	Neurons []*Neuron
	A       ActivationType
}

func NewLayer

func NewLayer(n int, activation ActivationType) *Layer

func (*Layer) ApplyBias

func (l *Layer) ApplyBias(weight WeightInitializer) []*Synapse

func (*Layer) Connect

func (l *Layer) Connect(next *Layer, weight WeightInitializer)

func (Layer) String

func (l Layer) String() string

type Linear

type Linear struct{}

func (Linear) Df

func (a Linear) Df(x float64) float64

func (Linear) F

func (a Linear) F(x float64) float64

type Loss

type Loss interface {
	F(estimate, ideal [][]float64) float64
	Df(estimate, ideal, activation float64) float64
}

func GetLoss

func GetLoss(loss LossType) Loss

type LossType

type LossType int
const (
	LossNone LossType = iota
	LossCrossEntropy
	LossBinaryCrossEntropy
	LossMeanSquared
)

func (LossType) String

func (l LossType) String() string

type MeanSquared

type MeanSquared struct{}

func (MeanSquared) Df

func (l MeanSquared) Df(estimate, ideal, activation float64) float64

func (MeanSquared) F

func (l MeanSquared) F(estimate, ideal [][]float64) float64

type Mode

type Mode int
const (
	ModeDefault Mode = iota
	ModeMultiClass
	ModeRegression
	ModeBinary
	ModeMultiLabel
)

type Neural

type Neural struct {
	Layers []*Layer
	Biases [][]*Synapse
	Config *Config
}

func FromDump

func FromDump(dump *Dump) *Neural

func NewNeural

func NewNeural(c *Config) *Neural

func Unmarshal

func Unmarshal(bytes []byte) (*Neural, error)

func (*Neural) ApplyWeights

func (n *Neural) ApplyWeights(weights [][][]float64)

func (Neural) Dump

func (n Neural) Dump() *Dump

func (*Neural) Forward

func (n *Neural) Forward(input []float64) error

func (Neural) Marshal

func (n Neural) Marshal() ([]byte, error)

func (*Neural) NumWeights

func (n *Neural) NumWeights() (num int)

func (*Neural) Predict

func (n *Neural) Predict(input []float64) []float64

func (*Neural) String

func (n *Neural) String() string

func (Neural) Weights

func (n Neural) Weights() [][][]float64

type Neuron

type Neuron struct {
	A     ActivationType `json:"-"`
	In    []*Synapse
	Out   []*Synapse
	Value float64 `json:"-"`
}

func NewNeuron

func NewNeuron(activation ActivationType) *Neuron

func (*Neuron) Activate

func (n *Neuron) Activate(x float64) float64

func (*Neuron) DActivate

func (n *Neuron) DActivate(x float64) float64

type ReLU

type ReLU struct{}

func (ReLU) Df

func (a ReLU) Df(y float64) float64

func (ReLU) F

func (a ReLU) F(x float64) float64

type Sigmoid

type Sigmoid struct{}

func (Sigmoid) Df

func (a Sigmoid) Df(y float64) float64

func (Sigmoid) F

func (a Sigmoid) F(x float64) float64

type Synapse

type Synapse struct {
	Weight  float64
	In, Out float64 `json:"-"`
	IsBias  bool
}

func NewSynapse

func NewSynapse(weight float64) *Synapse

type Tanh

type Tanh struct{}

func (Tanh) Df

func (a Tanh) Df(y float64) float64

func (Tanh) F

func (a Tanh) F(x float64) float64

type WeightInitializer

type WeightInitializer func() float64

func NewNormal

func NewNormal(stdDev, mean float64) WeightInitializer

func NewUniform

func NewUniform(stdDev, mean float64) WeightInitializer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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