Skip to content
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

Different ways to generate Semantic Pointers #201

Merged
merged 9 commits into from
Aug 22, 2018
Merged

Different ways to generate Semantic Pointers #201

merged 9 commits into from
Aug 22, 2018

Conversation

jgosmann
Copy link
Collaborator

@jgosmann jgosmann commented Jul 19, 2018

Motivation and context:
This PR adds a number of generators to generate vectors for Semantic Pointers. These can be passed to a Vocabulary to specify how new Semantic Pointers should be generated. This allows to easily create vocabularies with all unitary, orthogonal, or axis-aligned vectors. It also gives the user the possibility to program custom generation methods.

This removes the possibility to create a random pointer with SemanticPointer(d). Not sure if this has been widely used and if some short-form syntax should be put back in. With this PR one can do SemanticPointer(next(UnitLengthVectors(d)))) instead.

Closes #129.

Interactions with other PRs:

Based on #198 which introduces some changes to the code touched, but it is not essential to this PR.

How has this been tested?

Added and existing tests.

How long should this take to review?

  • Average (neither quick nor lengthy)

Types of changes:

  • New feature (non-breaking change which adds functionality)

Checklist:

  • I have read the CONTRIBUTING.rst document.
  • I have updated the documentation accordingly.
  • I have included a changelog entry.
  • I have added tests to cover my changes.
  • I have run the test suite locally and all tests passed.

Still to do:

  • Fix Python 2 compatibility.
  • Shorthand for pointer generation?
  • Add new classes to root module?

@jgosmann jgosmann added this to the 0.6 milestone Jul 19, 2018
@jgosmann jgosmann self-assigned this Jul 19, 2018
@jgosmann jgosmann removed their assignment Jul 19, 2018
@jgosmann jgosmann requested review from Seanny123 and bjkomer July 19, 2018 17:49
@jgosmann jgosmann self-assigned this Aug 20, 2018
@jgosmann jgosmann removed their assignment Aug 21, 2018
@jgosmann
Copy link
Collaborator Author

I'm still waiting on a review for this PR.

@Seanny123
Copy link
Collaborator

Seanny123 commented Aug 22, 2018

Could there be some basic parameter validation on the pointer_gen argument to spa.Vocabulary? Would it be reasonable to check if it's an iterator or at least callable? Currently, the error is only thrown once a pointer is created.

For example, the case:

import nengo_spa as spa

vo = spa.Vocabulary(32, pointer_gen="wat")

vo.populate("A; B; C")

@jgosmann
Copy link
Collaborator Author

I have to look into it. We want to avoid starting the iteration (because then we'd consume an element, which is a problem especially with AxisAlignedVectors or OrthogonalVectors), but maybe it is possible to try obtaining in iterator (however there might be non-trivial differences between Python 2 and 3). Or maybe we can check for the next/__next__ method on the object (not sure if all iterators have it, because there is the builtin next).

@jgosmann
Copy link
Collaborator Author

Turns out Nengo has is_iterable/is_string functions that I could use.

@jgosmann jgosmann merged commit 9d1b37f into master Aug 22, 2018
@jgosmann jgosmann deleted the pointer-gen branch August 22, 2018 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants