hopfield-0.1.0.1: Hopfield Networks, Boltzmann Machines and Clusters

Safe HaskellNone

Hopfield.TestUtil

Synopsis

Documentation

data Type Source

Constructors

H 
BM 

nonempty :: forall a. Gen [a] -> Gen [a]Source

mapMonad :: Monad m => (a -> b) -> m [a] -> m [b]Source

toGenVector :: Gen [a] -> Gen (Vector a)Source

Convert a list generator to a vector generator

signGen :: Gen IntSource

Generate a random sign (+/- 1)

binaryGen :: Gen IntSource

patternGen :: Type -> Int -> Gen PatternSource

patternGen n: Generates patterns of size n

patternRangeGen :: Type -> (Int, Int) -> Gen PatternSource

patternRangeGen (min, max) Generates patterns of size ranging between min and max

boundedListGen :: Gen a -> Int -> Gen [a]Source

boundedListGen g n: Generates lists (max length n) of the given Gen

patListGen :: Type -> Int -> Int -> Gen [Pattern]Source

patListGen t maxPatSize maxPatListSize Generates a list of patterns. The size of each pattern is less than maxPatSize. The size odf the list is less than maxPatListSize. The type is required in order to create types specific for Boltzmann, Hopfield etc.

patternsTupleGen :: Type -> Int -> Int -> Gen ([Pattern], [Pattern])Source

patternsTupleGen g m1 m2Generates a tuple of lists, as follows: Uses patListGen to generate 1 list of patterns with length less than m2. The list itself has to have length less than m1. The second element of a tuple is a list of patterns which have the same size as the patterns of the first list.

sameElemList :: a -> Gen [a]Source

sameElemVector :: a -> Gen (Vector a)Source

Generate vectors containing the same element replicated

allWeightsSame :: Int -> [[Double]]Source

Produces a matrix with 0's along the diagonal and 1's otherwise

boundedReplicateGen :: Int -> Gen a -> Gen [a]Source

boundedReplicateGen n g Generates lists containing g replicated. The list is bounded in size by n.

replaceAtN :: Int -> a -> [a] -> [a]Source

Replaces the nth element in the list with r

crosstalk :: HopfieldData -> Int -> Int -> IntSource

trainingPatsAreFixedPoints :: LearningType -> [Pattern] -> Gen BoolSource

Used as a property to check that patterns which are used to create the network are stable in respect to update

energyDecreasesAfterUpdate :: LearningType -> ([Pattern], [Pattern]) -> Gen BoolSource

Trains a network using training_pats and then updates each pattern in pats according to the weights of that network. The aim is to check that the energy decreases after each update.

boltzmannBuildGen :: Int -> Int -> Int -> Gen ([Pattern], Int)Source

boltzmannBuildGen maxPatSize maxPatListSize max_hidden Generates the structures required for creating a Boltzmann machine: a list of patterns together with the number of hidden layers, which has to be less than max_hidden.

buildBoltzmannCheck :: ([Pattern], Int) -> Gen BoolSource

boltzmannAndPatGen :: Int -> Int -> Int -> Gen ([Pattern], Int, Pattern)Source

Generates a list of patterns and the number of hidden layers used to train a Boltzmann machine, as well as a generic pattern to recognize on this machine.

probabilityCheck :: ([Pattern], Int, Pattern) -> Gen BoolSource

probabilityCheck (pats, nr_h, pat). Trains a Boltzmann machine using pats and nr_h and computes the activation probability for pat using this machine, and check if it is indeed a probability, ie in [0,1]

updateNeuronCheck :: Int -> ([Pattern], Int, Pattern) -> Gen BoolSource

buildIntTuple :: Gen (Int, Int)Source

binaryCheck :: (Int, Int) -> BoolSource

evalRandGen :: Rand StdGen a -> Gen aSource