Documentation ¶
Index ¶
- func Pattern2Image(p *Pattern, r image.Rectangle) image.Image
- type Network
- func (n Network) Bias() mat.Matrix
- func (n Network) Capacity() int
- func (n Network) Energy(p *Pattern) (float64, error)
- func (n Network) Memorised() int
- func (n *Network) Restore(p *Pattern, mode string, iters int) (*Pattern, error)
- func (n *Network) Store(patterns []*Pattern) error
- func (n Network) Weights() mat.Matrix
- type Pattern
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Network ¶
type Network struct {
// contains filtered or unexported fields
}
Network is Hopfield network
func NewNetwork ¶
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) Energy ¶
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) Restore ¶
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.
type Pattern ¶
type Pattern struct {
// contains filtered or unexported fields
}
Pattern is a data pattern
func AddNoise ¶
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 ¶
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 ¶
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