NEAL Home Page
Middlesex Logo

Code and Short Tutorial for Associative Memory

Code

Tutorial

  1. Get it running
    1. Grab the tarball, unzip, and untar it.
    2. 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).
    3. You should be able to test that the system runs by, for example,
      python testNestInherit.py 1 inputs/test4
    4. 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.
    5. 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].
  2. Explanation of the content
    1. In the inputs folder there are the following files:
      1. bases.txt, are the conceputal units with their isA relation
      2. props.txt, are the properties to be associated (that are later associated with bases and relations).
      3. rels.txt, are the relations (that are later associated with the properties and bases).
      4. assocs.txt, that are the specific combination of bases, props and rels
    2. The read files are:
      1. readAssocFile.py: it reads the association triples
      2. readInheritanceFile.py:it reads the inheritance file
      3. readUnitFile.py: it reads the units terminated with @@@
    3. The test files are:
      1. testNest3Assoc: it tests the association between units, properties and relations with Nest.
      2. testNestInherit: it tests the inheritance of the bases with Nest.
      3. testSpinn3Assoc: it tests the association between units, properties and relations with Spinnaker
      4. testSpinnInherit: it tests the inheritance of the bases with Spinnaker.
      5. runNestTests.sh: automated script for testing nest.
      6. runSpinn7Tests.sh and runSpinn8Tests.sh automated script for testing spinnaker 7 and 8.
    4. The python classes used are:
      1. 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.
      2. 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.
  3. 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.
      1. In the inputs folder, type ls test5* -l to have the list of all test5 files
      2. First test the original version of the associative memory.
        python testNest3Assoc.py 3 inputs/test5
      3. 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.
      4. python printPklFile.py results/inputs/test5Rels.pkl
        to see that the 0..7 neurons are firing.
      5. Now do the modification.
      6. Add the lizard unit in test5Bases.txt file; add it after butterfly making it the 11th item. Specify that lizard isA reptile
      7. 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.
      8. Add the association lizard climbs stone in the test5Assocs.txt file
      9. To test the new extension, run the test***3Assoc.py or run the test***Inherit.py
      10. (*** is Nest or Spinn).
      11. 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.
      12. You can modify testNest3Assoc.py so that it tests lizard climbs to return stone. ...CreateTwoPrimeTest(3,0,-1) to ...CreateTwoPrimeTests(11,9,-1).
      13. 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).