Documentation
¶
Overview ¶
Package feedforward implements a feedforward network type
Index ¶
- type FeedforwardNetwork
- func (f FeedforwardNetwork) Branch(reverse bool) (o []int)
- func (f *FeedforwardNetwork) Forget()
- func (f FeedforwardNetwork) Forward(in FeedforwardNetworkInput, l, worst, neg int) (inter Intermediate, computed bool)
- func (f *FeedforwardNetwork) GetBits() (ret byte)
- func (f *FeedforwardNetwork) GetClasses() (ret uint16)
- func (f FeedforwardNetwork) GetFrontBase(n int) (o int)
- func (f FeedforwardNetwork) GetFrontLayer(n int) int
- func (f FeedforwardNetwork) GetFrontOffset(n int) (o int)
- func (f FeedforwardNetwork) GetHashtron(n int) *hashtron.Hashtron
- func (f *FeedforwardNetwork) GetLastCells() (ret byte)
- func (f FeedforwardNetwork) GetLayer(n int) int
- func (f FeedforwardNetwork) GetLayerPosition(l, n int) int
- func (f FeedforwardNetwork) GetPosition(n int) int
- func (f FeedforwardNetwork) Infer2(input FeedforwardNetworkParityInOutput) (val uint16)
- func (f FeedforwardNetwork) IsMapLayerOf(n int) bool
- func (f FeedforwardNetwork) Len() (o int)
- func (f FeedforwardNetwork) LenFrontLayers() (o int)
- func (f FeedforwardNetwork) LenLayers() int
- func (f *FeedforwardNetwork) NewCombiner(layer layer.Layer)
- func (f *FeedforwardNetwork) NewLayer(n int, bits byte)
- func (f *FeedforwardNetwork) NewLayerP(n int, bits byte, premodulo uint32)
- func (f *FeedforwardNetwork) NewLayerPA(n int, bits byte, premodulo uint32)
- func (f *FeedforwardNetwork) NewLayerPI(n int, bits byte, premodulo uint32)
- func (f *FeedforwardNetwork) ReadCompressedWeights(w io.Reader) error
- func (f *FeedforwardNetwork) ReadCompressedWeightsFromFile(name string) error
- func (f *FeedforwardNetwork) ReadZlibWeights(w io.Reader) error
- func (f *FeedforwardNetwork) ReadZlibWeightsFromFile(name string) error
- func (f *FeedforwardNetwork) SetLayersP(premodulo uint32)
- func (f FeedforwardNetwork) Shuffle(reverse bool) (o []int)
- func (f *FeedforwardNetwork) Tally4(io FeedforwardNetworkParityInOutput, worst int, tally *datasets.Tally, ...)
- func (f *FeedforwardNetwork) WriteCompressedWeights(w io.Writer) error
- func (f *FeedforwardNetwork) WriteCompressedWeightsToFile(name string) error
- func (f *FeedforwardNetwork) WriteZlibWeights(w io.Writer) error
- func (f *FeedforwardNetwork) WriteZlibWeightsToFile(name string) error
- type FeedforwardNetworkInput
- type FeedforwardNetworkParityInOutput
- type FeedforwardNetworkParityInput
- type Intermediate
- type SingleValue
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) Branch ¶ added in v0.0.8
func (f FeedforwardNetwork) Branch(reverse bool) (o []int)
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) GetBits ¶ added in v0.0.12
func (f *FeedforwardNetwork) GetBits() (ret byte)
GetBits reports the number of bits predicted by this network
func (*FeedforwardNetwork) GetClasses ¶ added in v0.0.12
func (f *FeedforwardNetwork) GetClasses() (ret uint16)
GetBits reports the number of classes predicted by this network
func (FeedforwardNetwork) GetFrontBase ¶ added in v0.1.1
func (f FeedforwardNetwork) GetFrontBase(n int) (o int)
GetFrontBase returns the base number of hashtron for front layer. Each Layer and LayerPA counts as a front layer here.
func (FeedforwardNetwork) GetFrontLayer ¶ added in v0.1.1
func (f FeedforwardNetwork) GetFrontLayer(n int) int
GetLayer gets the layer number based on front layer number. Returns -1 on failure.
func (FeedforwardNetwork) GetFrontOffset ¶ added in v0.1.1
func (f FeedforwardNetwork) GetFrontOffset(n int) (o int)
GetFrontBase returns the offset number for front layer feature. Each Layer and LayerPA counts as a front layer here.
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) GetLastCells ¶ added in v0.1.0
func (f *FeedforwardNetwork) GetLastCells() (ret byte)
GetLastCells gets last cells
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) Infer2 ¶ added in v0.0.12
func (f FeedforwardNetwork) Infer2(input FeedforwardNetworkParityInOutput) (val uint16)
Infer2 infers the network output based on input, after being trained by using Tally4. This applies parity.
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) LenFrontLayers ¶ added in v0.1.1
func (f FeedforwardNetwork) LenFrontLayers() (o int)
LenLayers returns the number of front layers. Each Layer and LayerPA counts as a front layer here.
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) NewLayerPA ¶ added in v0.1.1
func (f *FeedforwardNetwork) NewLayerPA(n int, bits byte, premodulo uint32)
NewLayerPA adds a hashtron layer to the end of network with n hashtrons, each recognizing bits-bits, and input feature pre-modulo and pre-addition.
func (*FeedforwardNetwork) NewLayerPI ¶ added in v0.1.5
func (f *FeedforwardNetwork) NewLayerPI(n int, bits byte, premodulo uint32)
NewLayerPI adds a hashtron layer to the end of network with n hashtrons, each recognizing bits-bits, and input feature pre-modulo and inter-addition.
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) ReadZlibWeights ¶ added in v0.0.11
func (f *FeedforwardNetwork) ReadZlibWeights(w io.Reader) error
ReadZlibWeights reads model weights from a reader
func (*FeedforwardNetwork) ReadZlibWeightsFromFile ¶ added in v0.0.11
func (f *FeedforwardNetwork) ReadZlibWeightsFromFile(name string) error
ReadZlibWeightsFromFile 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) Tally4 ¶ added in v0.0.12
func (f *FeedforwardNetwork) Tally4(io FeedforwardNetworkParityInOutput, worst int, tally *datasets.Tally, loss func(actual, expected, mask uint32) uint32)
Tally3 tallies the network on ParityInOutput, tuning the worst-th hashtron in the network f storing data in tally. Loss can be nil if predicting power of 2 classes, or an actual minus expected difference or any other loss (0 means correct).
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
func (*FeedforwardNetwork) WriteZlibWeights ¶ added in v0.0.11
func (f *FeedforwardNetwork) WriteZlibWeights(w io.Writer) error
WriteZlibWeights writes model weights to a writer
func (*FeedforwardNetwork) WriteZlibWeightsToFile ¶ added in v0.0.11
func (f *FeedforwardNetwork) WriteZlibWeightsToFile(name string) error
WriteZlibWeightsToFile writes model weights to a lzw file
type FeedforwardNetworkInput ¶
FeedforwardNetworkInput is one individual input to the feedforward network
type FeedforwardNetworkParityInOutput ¶ added in v0.0.12
type FeedforwardNetworkParityInOutput interface { Feature(n int) uint32 Parity() uint16 Output() uint16 }
FeedforwardNetworkParityInOutput is one individual sample to the feedforward network with parity and expected network output
type FeedforwardNetworkParityInput ¶ added in v0.0.8
FeedforwardNetworkParityInput is one individual input to the feedforward network with parity
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