Code and Short Tutorial for Associative Memory
Code
Tutorial
-
Get it running
- Grab the tarball, unzip, and untar it.
- We've tested this in Ubuntu 14.04 and Ubuntu 16.04.5, with NEST
and spiNNaker. You should
get those running (or just nest if that's all you want).
- You should be able to test that the system runs by, for
example,
python testNestInherit.py 1 inputs/test4
- This should generate one pkl files in the results directory. You
can convert the pkl files to spike trains by
python printPklFile.py results/inherit.pkl > nestInherit1.sp
This is a text file of spikes (thus sp), that should end with
neurons 0-7 firing until about 500 ms.
- Once you have the sp file, you can speedly see the list of spiked neurons by
python printSpikeTrains.py nestInherit1.sp
showing the neurons that have fired, that are [0,1,2,3,4,5,6,7].
- Explanation of the content
- In the inputs folder there are the following files:
- bases.txt, are the conceputal units with their isA relation
- props.txt, are the properties to be associated (that are
later associated with bases and relations).
- rels.txt, are the relations (that are later associated with
the properties and bases).
- assocs.txt, that are the specific combination of bases, props and rels
- The read files are:
- readAssocFile.py: it reads the association triples
- readInheritanceFile.py:it reads the inheritance file
- readUnitFile.py: it reads the units terminated with @@@
- The test files are:
- testNest3Assoc: it tests the association between units, properties and relations with Nest.
- testNestInherit: it tests the inheritance of the bases with Nest.
- testSpinn3Assoc: it tests the association between units, properties and
relations with Spinnaker
- testSpinnInherit: it tests the inheritance of the bases with Spinnaker.
- runNestTests.sh: automated script for testing nest.
- runSpinn7Tests.sh and runSpinn8Tests.sh automated script for testing spinnaker 7 and 8.
- The python classes used are:
- stateMachineClass.py: the system is parsing a regular language,
which can be defined by a stateMachine. So, this class is used;
it's well tested and should work robustly for sentences.
- nealCoverClass.py: neal is the Neuromophic Embodied
Agents that Learn project. The idea is that we write
agents by combining modules (like this associative memory or
the parser). Then we
change one parameter (the simulator), and the system works
on different platforms. Unfortunately some pyNN functions
differ from simulator to simulator. These are included in
nealCoverClass to reduce the amount of branching (e.g.
if simulator == nest) in the modules.
- Design or modify an ontology and test it
If you want to design a new ontology you need to create a new sets of
bases, properties, relations and associations, otherwise you can
extend the ones that are present in the current input files. Let's do
the extension.
- In the inputs folder, type ls test5* -l to have the list of all test5 files
- First test the original version of the associative memory.
python testNest3Assoc.py 3 inputs/test5
- That will generate the net, send external stimulation the base Fish,
and the property Food, along with the activation to spread up the
base hierarchy. As Fish isA Animal, and Animal Eats Food, the Eats
Relationship should fire.
-
- python printPklFile.py results/inputs/test5Rels.pkl
to see that the 0..7 neurons are firing.
- Now do the modification.
- Add the lizard unit in test5Bases.txt file; add it after butterfly
making it the 11th item. Specify that
lizard isA reptile
- Add the climbs relation in test5Rels.txt file and add the
stone property in the test5Props.txt; make sure the stone is last,
just after wings, making it the 9th.
- Add the association lizard climbs stone in the test5Assocs.txt file
- To test the new extension, run the test***3Assoc.py or run the test***Inherit.py
(*** is Nest or Spinn).
- If you leave the test as above, you should get the same result, unless
you put climbs first, in which case eats will be 10..17.
- You can
modify testNest3Assoc.py so that it tests lizard climbs to return stone.
...CreateTwoPrimeTest(3,0,-1) to ...CreateTwoPrimeTests(11,9,-1).
-
Now as before run
python testNest3Assoc.py 3 inputs/test5
python printPklFile.py results/inputs/test5Rels.pkl
should generate spikes on the relation climbs (in our case 50..57 as
we put it last).
Now you have learnt how to modify the current ontology. In a similar
manner, you can create a new one making a new input folder with your
own ontology (e.g. mkdir newInputs then cp test5* to newInputs folder
to have the same named files that you can modify with your new
ontology).