gopfield: github.com/milosgajdos83/gopfield/hopfield Index | Files

package hopfield

import "github.com/milosgajdos83/gopfield/hopfield"

Index

Package Files

network.go pattern.go

func Pattern2Image Uses

func Pattern2Image(p *Pattern, r image.Rectangle) image.Image

Pattern2Image turns pattern p to a *lossy* Gray scaled image. Data to pixel transformation is lossy: non-positive elements are transformed to 0, otherwise 255

type Network Uses

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

Network is Hopfield network

func NewNetwork Uses

func NewNetwork(size int, method string) (*Network, error)

NewNetwork creates new Hopfield network which is trained using the training method and returns it. NewNetwork returns error if either non-positive size is supplied or unsupported training method is supplied.

func (Network) Bias Uses

func (n Network) Bias() mat64.Matrix

Bias returns network bias

func (Network) Capacity Uses

func (n Network) Capacity() int

Capacity returns network capacity

func (Network) Energy Uses

func (n Network) Energy(p *Pattern) (float64, error)

Energy calculates Hopfield network energy for a given pattern and returns it It returns error if the supplied pattern is nil or if it does not have the same dimension as number of network neurons.

func (Network) Memorised Uses

func (n Network) Memorised() int

Memorised returns count of memorised patterns

func (*Network) Restore Uses

func (n *Network) Restore(p *Pattern, mode string, iters int) (*Pattern, error)

Restore tries to restore supplied pattern from network through mode restore process and returns it. Mode can be either sync or async. If sync mode is requested, iters parameter is ignored. If async mode is requested network runs for iters iterations and returns the restored pattern. It returns error if invalid patterns is supplied, iters is negative or unsupported mode is supplied.

func (*Network) Store Uses

func (n *Network) Store(patterns []*Pattern) error

Store stores supplied patterns in network. Store returns error if patterns is nil or if any of the patterns do not have the same dimension as number network neurons.

func (Network) Weights Uses

func (n Network) Weights() mat64.Matrix

Weights returns network weights

type Pattern Uses

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

Pattern is a data pattern

func AddNoise Uses

func AddNoise(p *Pattern, pcnt int) *Pattern

AddNoise adds random noise to pattern p and returns it. Noise is added by flipping the sign of existing pattern value. It allows to specify the percentage of noise via pcnt parameter. AddNoise modifies the pattern p in place.

func Encode Uses

func Encode(data []float64) *Pattern

Encode encodes data to a pattern of values: +1/-1. Non-positive data items are set to -1, positive ones are set to +1 Encode modifies the data slice in place and returns pointer to Pattern.

func Image2Pattern Uses

func Image2Pattern(img image.Image) *Pattern

Image2Pattern transforms img raw data into binary encoded pattern that can be used in Hopfield Network It first turns the image into a Grey scaled image and then encodes its pixels into binary values of -1/+1

func (*Pattern) At Uses

func (p *Pattern) At(i int) float64

At returns valir of patttern on position i

func (*Pattern) Len Uses

func (p *Pattern) Len() int

Len returns the length of the pattern

func (*Pattern) RawData Uses

func (p *Pattern) RawData() []float64

RawData returns pattern raw data

func (*Pattern) Set Uses

func (p *Pattern) Set(i int, val float64) error

Set sets value on position i

func (*Pattern) String Uses

func (p *Pattern) String() string

String implements Stringer interface

func (*Pattern) Vec Uses

func (p *Pattern) Vec() *mat64.Vector

Vec returns internal data vector

Package hopfield imports 7 packages (graph). Updated 2017-03-21. Refresh now. Tools for package owners.