{"action":"created","issue":{"url":"https://api.github.com/repos/nengo/nengo/issues/891","labels_url":"https://api.github.com/repos/nengo/nengo/issues/891/labels{/name}","comments_url":"https://api.github.com/repos/nengo/nengo/issues/891/comments","events_url":"https://api.github.com/repos/nengo/nengo/issues/891/events","html_url":"https://github.com/nengo/nengo/issues/891","id":115128971,"number":891,"title":"Hetero-associative relationships in spa.AssociativeMemory","user":{"login":"ikajic","id":2485670,"avatar_url":"https://avatars.githubusercontent.com/u/2485670?v=3","gravatar_id":"","url":"https://api.github.com/users/ikajic","html_url":"https://github.com/ikajic","followers_url":"https://api.github.com/users/ikajic/followers","following_url":"https://api.github.com/users/ikajic/following{/other_user}","gists_url":"https://api.github.com/users/ikajic/gists{/gist_id}","starred_url":"https://api.github.com/users/ikajic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ikajic/subscriptions","organizations_url":"https://api.github.com/users/ikajic/orgs","repos_url":"https://api.github.com/users/ikajic/repos","events_url":"https://api.github.com/users/ikajic/events{/privacy}","received_events_url":"https://api.github.com/users/ikajic/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nengo/nengo/labels/discussion","name":"discussion","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":16,"created_at":"2015-11-04T19:28:29Z","updated_at":"2015-11-04T20:41:09Z","closed_at":null,"body":"From the current `spa.AssociativeMemory` documentation:\r\n```\r\ninput_vocab: list of numpy.array, spa.Vocabulary\r\n    The vocabulary (or list of vectors) to match.\r\noutput_vocab: list of numpy.array, spa.Vocabulary, optional\r\n    The vocabulary (or list of vectors) to be produced for each match. If\r\n    not given, the associative memory will act like an auto-associative\r\n    memory (cleanup memory).\r\n```\r\n\r\none could conclude that when the `output_vocab` is passed the memory should act like a hetero-associative memory, fairly standard use-case. By definition, this means that the network outputs a different stored pattern from the presented one, and this relationship is somehow stored in the network weights.\r\nNow, when I try to use `spa.AssociativeMemory` in this way, this mapping doesn't happen.\r\nHere a simple example:\r\n\r\n```python\r\nimport nengo\r\nfrom nengo import spa\r\nimport matplotlib.pyplot as plt\r\n\r\nvocab_input = spa.Vocabulary(dimensions=16)\r\nvocab_output = spa.Vocabulary(dimensions=16)\r\n\r\nvocab_input.parse('ONE + TWO')\r\nvocab_output.parse('TWO + ONE')\r\n\r\nwith nengo.Network('model', seed=1) as model:\r\n    assoc_mem = spa.AssociativeMemory(input_vocab=vocab_input, output_vocab=vocab_output)\r\n    \r\n    input_node = nengo.Node(output=vocab_input['ONE'].v, label='input')\r\n    nengo.Connection(input_node, assoc_mem.input)\r\n\r\n    input_probe = nengo.Probe(input_node)\r\n    output_probe = nengo.Probe(assoc_mem.output, synapse=0.03)\r\n    \r\nsim = nengo.Simulator(model)\r\nsim.run(.5)\r\nt = sim.trange()\r\n\r\ninput_net = sim.data[input_probe]\r\noutput_net = sim.data[output_probe]\r\n\r\nplt.figure(figsize=(16, 4))\r\nplt.subplot(1, 2, 1)\r\nplt.plot(t, nengo.spa.similarity(input_net, vocab_input))\r\nplt.title(\"Input similarity\")\r\nplt.xlabel('Time')\r\nplt.ylim(top=1.1)\r\nplt.legend(vocab_input.keys, loc='best')\r\nplt.subplot(1, 2, 2)\r\nplt.plot(t, nengo.spa.similarity(output_net, vocab_output))\r\nplt.title(\"Output similarity\")\r\nplt.xlabel('Time')\r\nplt.legend(vocab_output.keys, loc='best')\r\n\r\nplt.show()\r\n```\r\n\r\nFor a hetero-associative memory I would expect to see \"TWO\" in the second plot.\r\n\r\nNow, is what is currently happening really the intended behaviour? If it really is, what is the idea behind it? \r\n"},"comment":{"url":"https://api.github.com/repos/nengo/nengo/issues/comments/153856159","html_url":"https://github.com/nengo/nengo/issues/891#issuecomment-153856159","issue_url":"https://api.github.com/repos/nengo/nengo/issues/891","id":153856159,"user":{"login":"ikajic","id":2485670,"avatar_url":"https://avatars.githubusercontent.com/u/2485670?v=3","gravatar_id":"","url":"https://api.github.com/users/ikajic","html_url":"https://github.com/ikajic","followers_url":"https://api.github.com/users/ikajic/followers","following_url":"https://api.github.com/users/ikajic/following{/other_user}","gists_url":"https://api.github.com/users/ikajic/gists{/gist_id}","starred_url":"https://api.github.com/users/ikajic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ikajic/subscriptions","organizations_url":"https://api.github.com/users/ikajic/orgs","repos_url":"https://api.github.com/users/ikajic/repos","events_url":"https://api.github.com/users/ikajic/events{/privacy}","received_events_url":"https://api.github.com/users/ikajic/received_events","type":"User","site_admin":false},"created_at":"2015-11-04T20:41:09Z","updated_at":"2015-11-04T20:41:09Z","body":"I see. So, the order in which the keys are created does not necessarily reflect the desired mapping. Yup, that makes sense!"}}