feedforward

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Overview

Package feedforward implements a feedforward network type

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FeedforwardNetwork

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

FeedforwardNetwork is the feedforward network

func (FeedforwardNetwork) Forward

func (f FeedforwardNetwork) Forward(in FeedforwardNetworkInput, l, worst, neg int) (inter Intermediate, computed bool)

Forward solves the intermediate value (net output after layer l based on that layer's input in) and the bit returned by worst hashtron is optionally negated (using neg == 1) and returned as computed.

func (FeedforwardNetwork) GetHashtron

func (f FeedforwardNetwork) GetHashtron(n int) *hashtron.Hashtron

GetHashtron gets n-th hashtron pointer in the network. You can currently write a new hashtron into the pointer, but you might not be able to in the future.

func (FeedforwardNetwork) GetLayer

func (f FeedforwardNetwork) GetLayer(n int) int

GetLayer gets the layer number of hashtron based on hashtron number. Returns -1 on failure.

func (FeedforwardNetwork) GetLayerPosition

func (f FeedforwardNetwork) GetLayerPosition(l, n int) int

GetLayerPosition gets the position of hashtron within layer based on the overall hashtron number and overall layer. Returns -1 on failure.

func (FeedforwardNetwork) GetPosition

func (f FeedforwardNetwork) GetPosition(n int) int

GetPosition gets the position of hashtron within layer based on the overall hashtron number. Returns -1 on failure.

func (FeedforwardNetwork) Infer

Infer infers the network output based on input

func (FeedforwardNetwork) IsMapLayerOf

func (f FeedforwardNetwork) IsMapLayerOf(n int) bool

IsMapLayerOf checks if hashtron n lies in the final layer of the network.

func (FeedforwardNetwork) Len

func (f FeedforwardNetwork) Len() (o int)

Len returns the number of hashtrons which need to be trained inside the network.

func (FeedforwardNetwork) LenLayers

func (f FeedforwardNetwork) LenLayers() int

LenLayers returns the number of layers. Each Layer and Combiner counts as a layer here.

func (*FeedforwardNetwork) NewCombiner

func (f *FeedforwardNetwork) NewCombiner(layer layer.Layer)

NewCombiner adds a combiner layer to the end of network

func (*FeedforwardNetwork) NewLayer

func (f *FeedforwardNetwork) NewLayer(n int, bits byte)

NewLayer adds a hashtron layer to the end of network with n hashtrons, each recognizing bits bits.

func (*FeedforwardNetwork) NewLayerP added in v0.0.4

func (f *FeedforwardNetwork) NewLayerP(n int, bits byte, premodulo uint32)

NewLayerP adds a hashtron layer to the end of network with n hashtrons, each recognizing bits bits, and input feature pre-modulo.

func (*FeedforwardNetwork) ReadCompressedWeights added in v0.0.6

func (f *FeedforwardNetwork) ReadCompressedWeights(w io.Reader) error

ReadCompressedWeights reads model weights from a reader

func (FeedforwardNetwork) ReadCompressedWeightsFromFile added in v0.0.6

func (f FeedforwardNetwork) ReadCompressedWeightsFromFile(name string) error

ReadCompressedWeightsFromFile reads model weights from a lzw file

func (*FeedforwardNetwork) SetLayersP added in v0.0.4

func (f *FeedforwardNetwork) SetLayersP(premodulo uint32)

SetLayersP sets an input feature pre-modulo to layers.

func (FeedforwardNetwork) Shuffle added in v0.0.4

func (f FeedforwardNetwork) Shuffle(reverse bool) (o []int)

func (*FeedforwardNetwork) Tally

func (f *FeedforwardNetwork) Tally(in, output FeedforwardNetworkInput, worst int, tally *datasets.Tally, less func(i, j FeedforwardNetworkInput) bool)

Tally tallies the network on input/output pair with respect to to-be-trained worst hashtron. The tally is stored into thread safe structure Tally. Two ouputs i, j can be compared to be less worse using the function less (returning true if output i is less worse than output j).

func (*FeedforwardNetwork) Tally2 added in v0.0.4

func (f *FeedforwardNetwork) Tally2(in, output FeedforwardNetworkInput, worst int, tally *datasets.Tally,
	loss func(i FeedforwardNetworkInput) uint32)

Tally2 tallies the network like Tally, except it can also optimize n-way classifiers. Loss is 0 if the output is correct, below or equal to maxloss otherwise.

func (FeedforwardNetwork) WriteCompressedWeights added in v0.0.6

func (f FeedforwardNetwork) WriteCompressedWeights(w io.Writer) error

WriteCompressedWeights writes model weights to a writer

func (FeedforwardNetwork) WriteCompressedWeightsToFile added in v0.0.6

func (f FeedforwardNetwork) WriteCompressedWeightsToFile(name string) error

WriteCompressedWeightsToFile writes model weights to a lzw file

type FeedforwardNetworkInput

type FeedforwardNetworkInput interface {
	Feature(n int) uint32
}

FeedforwardNetworkInput is one individual input to the feedforward network

type Intermediate

type Intermediate interface {

	// Feature extracts n-th feature from Intermediate
	Feature(n int) uint32

	// Disregard reports whether Intermediate doesn't regard n-th bit as affecting the output
	Disregard(n int) bool
}

Intermediate is an intermediate value used as both layer input and layer output in optimization

type SingleValue

type SingleValue uint32

SingleValue is a single value returned by the final layer

func (SingleValue) Disregard

func (v SingleValue) Disregard(n int) bool

Disregard reports whether SingleValue doesn't regard n-th bit as affecting the output

func (SingleValue) Feature

func (v SingleValue) Feature(n int) uint32

Feature extracts the feature from SingleValue

Jump to

Keyboard shortcuts

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