{"action":"opened","issue":{"url":"https://api.github.com/repos/nengo/nengo/issues/696","labels_url":"https://api.github.com/repos/nengo/nengo/issues/696/labels{/name}","comments_url":"https://api.github.com/repos/nengo/nengo/issues/696/comments","events_url":"https://api.github.com/repos/nengo/nengo/issues/696/events","html_url":"https://github.com/nengo/nengo/issues/696","id":67201040,"number":696,"title":"vocab.transform_to in spa connections","user":{"login":"drasmuss","id":1952220,"avatar_url":"https://avatars.githubusercontent.com/u/1952220?v=3","gravatar_id":"","url":"https://api.github.com/users/drasmuss","html_url":"https://github.com/drasmuss","followers_url":"https://api.github.com/users/drasmuss/followers","following_url":"https://api.github.com/users/drasmuss/following{/other_user}","gists_url":"https://api.github.com/users/drasmuss/gists{/gist_id}","starred_url":"https://api.github.com/users/drasmuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drasmuss/subscriptions","organizations_url":"https://api.github.com/users/drasmuss/orgs","repos_url":"https://api.github.com/users/drasmuss/repos","events_url":"https://api.github.com/users/drasmuss/events{/privacy}","received_events_url":"https://api.github.com/users/drasmuss/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-08T19:26:02Z","updated_at":"2015-04-08T19:26:02Z","closed_at":null,"body":"Was playing around with the associative memory, and noticed this effect.  Here's a stripped down script to illustrate:\r\n```python\r\nwith spa.SPA() as model:\r\n    d = 8\r\n\r\n    parent = model.get_default_vocab(d)\r\n    for i in range(4):\r\n        print chr(65 + i), parent[chr(65 + i)]\r\n\r\n    child = parent.create_subset([\"A\", \"B\"])\r\n\r\n    model.buffer = spa.Buffer(d)\r\n    model.assoc = spa.AssociativeMemory(child)\r\n\r\n    actions = spa.Actions(\"assoc = buffer\")\r\n    model.cortical = spa.Cortical(actions)\r\n\r\n    for k in child.keys:\r\n        print k, child[k]\r\n    print parent.transform_to(child)\r\n```\r\n\r\nThere's a couple things going on here.\r\n\r\n1. The `child` vocabulary now contains all the vectors in `parent`, not just the subset it was initialized with.  This is because the `Cortical` module, when it creates a connection from `buffer` to `assoc`, calls `parent.transform_to(child)`, which adds all the vocabulary in `parent` to `child`.  It's not really obvious how or why that happens unless you go digging through the code, so it's one of those \"gotchas\" for new users.\r\n\r\n2. The vectors that get added to `child` do not match the vectors in `parent`.  So in the above example, \"A\" and \"B\" would match, but \"C\" and \"D\" would not.  Again, probably unexpected to most people.\r\n\r\n3. The above are just usability issues, but I think this also has an impact on performance.  This is because the output of `transform_to` is a matrix, which is being used as the transform between `buffer` and `assoc`.  So when these new vectors get added in, what that's doing is giving you a noisy transform matrix, when what you'd actually like is no transform at all (you just want to feed \"A\" and \"B\" directly from `buffer` to `assoc`).  Note that this is true even if all the vectors did exactly match in `parent` and `child` (you're still going to get an unwanted, noisy transform matrix).\r\n\r\nHowever, I do not have the best grasp on the internal workings of `spa`, so it's very possible that I'm misunderstanding something here.  Or there's a better way to do this that doesn't run into this problem.  That's the main reason I'm posting this, to get @tcstewar's insight.\r\n\r\n"}}