learn

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2021 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Backpropagation

func Backpropagation(n *neural.Network, in, ideal []float64, speed float64)

Backpropagation uses backprop on the network

func Learn

func Learn(n *neural.Network, in, ideal []float64, speed float64)

Learn applies backprop on the network

func Learner

func Learner(n *neural.Network, samples []Sample, speed float64)

Learner learns all samples and applies backprop on the network

Types

type Deltas

type Deltas [][]float64

Deltas holds the deltas from the learner

type Sample

type Sample struct {
	Vector      []float64
	Output      []float64
	Value       float64
	VectorHash  string
	OutputHash  string
	Label       string
	ClassNumber int
}

Sample holds the sample data, value is just used for regression annotation

func NewClassificationSample

func NewClassificationSample(vector, output []float64, classLabel string) *Sample

NewClassificationSample creates a new sample data point for classification

func NewRegressionSample

func NewRegressionSample(vector []float64, output float64, classLabel string) *Sample

NewRegressionSample creates a new sample data point for classification

func (*Sample) GetHash

func (s *Sample) GetHash() string

GetHash calculates the has of feature vector and output and returns it

func (*Sample) UpdateHashes

func (s *Sample) UpdateHashes()

UpdateHashes updates hashes of vector and output vector

type Set

type Set struct {
	Samples      []*Sample
	VectorHashes []string
	OutputHashes []string
	ClassToLabel map[int]string
	Usage        neural.NetworkType
}

Set holds the samples and the output labels

func NewSet

func NewSet(usage neural.NetworkType) *Set

NewSet creates a new set of empty data samples

func (*Set) AddClass

func (s *Set) AddClass(label string) (bool, error)

AddClass returns the classes in the set

func (*Set) AddSample

func (s *Set) AddSample(sample *Sample) error

AddSample adds samples to the set

func (*Set) GenerateOutputVector

func (s *Set) GenerateOutputVector(label string) []float64

GenerateOutputVector generates the output vector for a classification task and a specific label

func (*Set) GetClasses

func (s *Set) GetClasses() []string

GetClasses returns the classes in the set

func (*Set) LoadFromCSV

func (s *Set) LoadFromCSV(path string) (bool, error)

LoadFromCSV where the last dimension is the label

func (*Set) LoadFromSVMFile

func (s *Set) LoadFromSVMFile(path string) (bool, error)

LoadFromSVMFile load data from an svm problem file

func (*Set) SampleExists

func (s *Set) SampleExists(test *Sample) bool

SampleExists looks up in the set if the presented example already exists

Jump to

Keyboard shortcuts

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