nn

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MSE

func MSE(pred, target []float64) (loss float64, dPred []float64)

func Softmax

func Softmax(logits []float64) []float64

func SoftmaxCrossEntropy

func SoftmaxCrossEntropy(logits []float64, target int) (loss float64, dLogits []float64)

Types

type Activation

type Activation uint8
const (
	Linear Activation = iota

	ReLU
)

type Adam

type Adam struct {
	// contains filtered or unexported fields
}

func NewAdam

func NewAdam(m *MLP, lr float64) *Adam

func (*Adam) Step

func (a *Adam) Step(m *MLP, g *Grads)

type Config

type Config struct {
	Sizes  []int
	Hidden Activation
	Output Activation
	Seed   int64
}

type Grads

type Grads struct {
	// contains filtered or unexported fields
}

type MLP

type MLP struct {
	// contains filtered or unexported fields
}

func FromSnapshot

func FromSnapshot(s Saved) (*MLP, error)

func Load

func Load(path string) (*MLP, error)

func New

func New(cfg Config) *MLP

func (*MLP) Forward

func (m *MLP) Forward(x []float64) []float64

func (*MLP) InDim

func (m *MLP) InDim() int

func (*MLP) OutDim

func (m *MLP) OutDim() int

func (*MLP) Save

func (m *MLP) Save(path string) error

func (*MLP) Snapshot

func (m *MLP) Snapshot() Saved

func (*MLP) TrainBatch

func (m *MLP) TrainBatch(opt *Adam, xs [][]float64, targets []int) (loss float64)

type Saved

type Saved struct {
	SchemaVersion int         `json:"schema_version"`
	Sizes         []int       `json:"sizes"`
	Hidden        Activation  `json:"hidden"`
	Output        Activation  `json:"output"`
	Weights       [][]float64 `json:"weights"`
	Biases        [][]float64 `json:"biases"`
}

Jump to

Keyboard shortcuts

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