goregression

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2024 License: MIT Imports: 9 Imported by: 0

README

goregression

The goal is to build a regression nueral net on top of gonum.org/v1/gonum/mat

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BiLn = Activation{
	Activate: func(f float64) float64 {
		if f == 0 {
			return 0
		}
		if f > 0 {
			return math.Log(1 + f)
		}
		return -math.Log(1 - f)
	},
	Derivative: func(f float64) float64 {
		if f == 0 {
			return 1
		}
		if f > 0 {
			return 1 / (1 + f)
		}
		return 1 / (1 - f)
	},
	Show: func() string { return "BiLn" },
}
View Source
var ReLU = Activation{
	Activate: func(f float64) float64 {
		return max(0, f)
	},
	Derivative: func(f float64) float64 {
		if f > 0 {
			return 1
		}
		return 0
	},
	Show: func() string { return "ReLU" },
}
View Source
var Sigmoid = Activation{
	Activate: sigmoid,
	Derivative: func(f float64) float64 {
		s := sigmoid(f)
		return s * (1 - s)
	},
	Show: func() string { return "Sigmoid" },
}
View Source
var Tanh = Activation{
	Activate: math.Tanh,
	Derivative: func(f float64) float64 {
		t := math.Tanh(f)
		return 1 - t*t
	},
	Show: func() string { return "Tanh" },
}

Functions

This section is empty.

Types

type Activation

type Activation struct {
	Activate   func(float64) float64
	Derivative func(float64) float64
	Show       func() string
}

func Linear

func Linear(slope float64) Activation

func Scale

func Scale(factor float64, General Activation) Activation

func Strech

func Strech(factor float64, General Activation) Activation

func (Activation) MarshalJSON added in v0.0.2

func (a Activation) MarshalJSON() ([]byte, error)

func (Activation) String added in v0.0.2

func (a Activation) String() string

func (*Activation) UnmarshalJSON added in v0.0.2

func (a *Activation) UnmarshalJSON(text []byte) error

type Job

type Job func()

type Model

type Model struct {
	Weights  []mat.Mutable
	Internal Activation
	Output   Activation
}

func NewModel

func NewModel(source *rand.Rand, Internal Activation, Output Activation, layers ...int) *Model

func (*Model) Clone

func (m *Model) Clone() *Model

func (Model) InputSize

func (m Model) InputSize() int

func (Model) OutputSize

func (m Model) OutputSize() int

func (Model) Predict

func (m Model) Predict(start mat.Vector) mat.Vector

func (Model) String

func (m Model) String() string

type TrainingContext

type TrainingContext struct {
	*Model
	GeneratedNodes []*mat.VecDense
	PreNormalized  []*mat.VecDense
}

func (*TrainingContext) Train

func (tc *TrainingContext) Train(trainingSet [][]mat.Vector, iterations int, lrate float64, debug func(epoch int, err float64))

func (*TrainingContext) TrainChunked

func (tc *TrainingContext) TrainChunked(trainingSet [][]mat.Vector, iterations int, workers int, chunksize int, lrate float64, debug func(epoch int, current *Model))

type Workers

type Workers struct {
	sync.WaitGroup
	// contains filtered or unexported fields
}

func (*Workers) Go

func (w *Workers) Go(j Job)

func (*Workers) Start

func (w *Workers) Start(size int)

func (*Workers) Stop

func (w *Workers) Stop()

Jump to

Keyboard shortcuts

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