ff

package
v0.0.0-...-31ccac1 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2021 License: MIT Imports: 3 Imported by: 1

README

The Perceptron

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Perceptron = func(module *ml.Module, weights xmath.VectorGenerator) NeuronFactory {
	return func(p int, meta net.Meta) *Neuron {
		return &Neuron{
			Module: *module,
			memory: memory{
				input: xmath.Vec(p),
			},
			Meta: meta,
			learn: learn{
				weights: weights(p, meta.Index),
			},
		}
	}
}

Functions

This section is empty.

Types

type Layer

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

Layer represents a layer in the network, it will receive a vector of inputs and transform them into another vectopr of inputs. Not necessarily of the same size.

func NewLayer

func NewLayer(n, m int, factory net.NeuronFactory, index int) *Layer

NewLayer creates a new layer.

func (*Layer) Backward

func (l *Layer) Backward(err xmath.Vector) xmath.Vector

Backward receives all the errors/diffs from the following layer it returns the errors/diffs for the previous layer

func (*Layer) Forward

func (l *Layer) Forward(v xmath.Vector) xmath.Vector

Forward takes as input the outputs of all the neurons of the previous layer it returns the output of all the neurons of the current layer

func (*Layer) Size

func (l *Layer) Size() (int, int)

Size returns the input and output size of the layer.

func (*Layer) Weights

func (l *Layer) Weights() map[net.Meta]net.Weights

Weights returns the weights of the current layer for storing the network state.

type Network

type Network struct {
	net.Info
	net.Config
	// contains filtered or unexported fields
}

func New

func New(inputSize, outputSize int) *Network

func (*Network) Add

func (n *Network) Add(s int, factory net.NeuronFactory) *Network

func (*Network) Loss

func (n *Network) Loss(loss ml.Loss)

func (*Network) Predict

func (n *Network) Predict(input xmath.Vector) xmath.Vector

func (*Network) Train

func (n *Network) Train(input xmath.Vector, expected xmath.Vector) (err xmath.Vector, weights map[net.Meta]net.Weights)

type Neuron

type Neuron struct {
	ml.Module
	net.Meta
	// contains filtered or unexported fields
}

type NeuronFactory

type NeuronFactory func(p int, meta net.Meta) *Neuron

NeuronFactory is a factory for construction of neuron within the context of a neuron layer / network

type XNetwork

type XNetwork struct {
	*Network
}

func XNew

func XNew(inputSize, outputSize int) *XNetwork

func (*XNetwork) Add

func (xn *XNetwork) Add(s int, factory NeuronFactory) *XNetwork

Jump to

Keyboard shortcuts

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