-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Making vocabulary subsets reinterpret automatically #183
Comments
|
In other words, I don't see how this could happen automatically. |
Alternatively, would it be worth making this syntax more elegant by allowing a vocab to be used as a context mananger? Like, if I wrapped a whole statement in Upon further consideration, this is a really bad idea, because although it works in my ideal use case, it could lead to a lot of confusion if someone creates a network inside of the vocab context. |
I think I had some insight into the underlying problem that makes it hard to handle this nicely: We are using the vocab for two different things. First, it is used for the type system (ensuring that we only connect modules with matching vocabs and allowing type inference for the symbols). Second, we use to denote which Semantic Pointers have meaning in a module (which are those we want to visualize in a plot). Unfortunately, the appropriate vocabularies in these two cases are not the same. In the example above, all states should use num_vision * ss.NUM + color_vision * ss.COLOR >> combined However, for visualizing the content of Not sure what possible options are to improve on this. One suggestion could be to use vocab that is appropriate according to the type system ( |
Hmm... I'd actually thought that the reason we have vocab subsets was to deal with this. I'd thought that vocab subsets were the same "type" as far as connecting modules goes (i.e. no transformation added), but they'd be treated differently in the gui. What are the other use cases of vocab subsets? I'm sure we've talked about them before but it's not coming to mind for me.... The only other thing I can think of is that cleanup memories could use a subset to only clean up to a subset of the items, but that can also be handled in other ways..... |
Not much thought went into subsets so far as they were basically copied from the legacy SPA system. One of the main uses cases to me was for clean-up memories, but #177 enforces the use of the mapping argument and adds some syntactic suger so that this use case should fall away. So far subset vocabularies are completely separate vocabularies and require explicit Note that making the subset type compatible to the superset vocabulary still requires to explicitely get the |
I spend some more thought on this and #69 (how to add different binding methods to Nengo SPA) and came to the conclusion that vocabularies might have originally been intended for plotting in the GUI, but we should move away from that. The GUI might base the default displayed Semantic Pointer expressions on the vocabulary, but more fine grained control over the displayed pointers should be provided by the GUI itself. It feels somewhat wrong to me to make special allowances for Nengo GUI in a project not dependent on Nengo GUI. Also, vocabularies have another important task in Nengo SPA now by ensuring type safety and I am thinking about tying the specific instance of employed binding operation to a vocabulary. That would allow to use different binding operations in the same model, but ensures that they are not accidentally mixed (due to type safety). So far I couldn't think of any case where there is not a 1:1 mapping between the vocabulary and the binding operation to use. Also, some special vocabularies (like axis-aligned vectors, #129) might require some special binding operation (or the other way around a specific binding operation might require vectors created in a specific way). For the original issue this means: Use a single vocab and create subsets for the plotting. If you want to use Nengo GUI, you might have to do what you are doing now unfortunately, until the SPA plots get improved. |
Does this also imply that if the SPA plots were improved, then Nengo SPA would proceed and better support for type-safety? Specifically, "making the subset type compatible to the superset vocabulary". Alternatively, how did you imagine this would proceed? |
Everything in Nengo SPA would stay as it is right now. |
I thought a bit more about this and think there are in principle three options:
I think it might be possible to find consistent answers to the open questions in option 3 and implement a working SPA system based on that, but it is a major job with what seems to me minimal benefit. Finally, I just realized that the originall problem might be partially addressed by allowing to disable the type checking (which would only require dimensions to match up and basically do reinterprets). Something like: with spa.unsafe:
num_vision * top_vocab['NUM'] + color_vision * top_vocab['COLOR'] >> combined |
Another reason against option 3: I was thinking about using vocabs to track which binding operation to use, but this only makes sense when both operands are always from the same vocab. |
One benefit of having an option to disable the type checking is that it would allow One common use case of vocabularies involves defining some SPs in terms of others, not necessarily from the same vocabulary. For example, if I have one vocabulary for goals, and another for objects, I might want to make a new vocabulary that includes SPs for actions that are related to these goals and objects in some way, e.g. Is there are recommended approach to doing this sort of thing in I might be missing something, but |
My viewpoint is that the recommended approach should be to define a single vocabulary. You can keep lists or sets of the keys of the subsets around and use the union to easily define the full vocabulary as done in @Seanny123 example in the first post. The main situation where subset vocabularies are actually needed still seems to me to me when comparing a semantic pointer to the vocab for plotting as some elements in the vocab might be irrelevant. In that case it is easy to create the desired subset vocabulary and One additional situation where multiple vocabs might be desired is when the max. similarity constraint should not be ensured across for example the goal and object vectors. But this seems to be problematic when combining goals and objects in a single vector and thus I'm not convinced that this needs to be any easier than it already is. It is also slightly different from the issue how subvocabs should be treated from their parent vocabulary, because instead of creating subvocabs, this requires creating supersets. |
OK, that sounds reasonable - the idea being to use sets of keys to keep track if different items of interest rather than grouping them in to separate vocabs. |
Closing as it seems everyone is more or less convinced that my proposal is the way to go (and the algebra PR #198 has been merged). |
If I have one vocab which I:
Ideally, I shouldn't have to do
spa.reinterpret
for each module. Here's an example of what I mean in code:Here's how I need to modify the code to make it work:
@tcstewar said this should happen automatically, but I might have just described it incorrectly to him.
The text was updated successfully, but these errors were encountered: