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

Combined decoders and transform #729

Merged
merged 3 commits into from
Jul 13, 2015
Merged

Combined decoders and transform #729

merged 3 commits into from
Jul 13, 2015

Conversation

hunse
Copy link
Collaborator

@hunse hunse commented Jun 9, 2015

I combined decoders and transform in the connection builder. This makes things a lot cleaner, and it should be easier for users too, since they don't have to decide between probing 'transform' or 'decoders' when doing learning (right now it depends on the type of connection).

I also improved slicing, so we support slicing on neuron-to-neuron connections.

@hunse
Copy link
Collaborator Author

hunse commented Jun 10, 2015

Okay, this is ready for review!

@tbekolay
Copy link
Member

I also improved slicing, so we support slicing on neuron-to-neuron connections.

Oh awesome, I ran into that bug recently :)

@arvoelke
Copy link
Contributor

Do we have any situations where we learn decoders on PES and then apply a transform? Would that still work? Say if I'm learning a scalar and then projecting that into a higher dimensional space. Or do we now need to apply the same transform to the error signal in this case?

@hunse
Copy link
Collaborator Author

hunse commented Jun 12, 2015

Do we have any situations where we learn decoders on PES and then apply a transform? Would that still work? Say if I'm learning a scalar and then projecting that into a higher dimensional space. Or do we now need to apply the same transform to the error signal in this case?

I think you would need to apply the same transform on the error signal, or at least account for it in some way.

hunse referenced this pull request Jun 14, 2015
Previously, we used the type of the pre or post object as a clue to
what the learning rule modifies. This makes it more explicit by saying
what signal the learning rule actually modifies. This will make it
easier to implement learning rules that modify other quantities,
like for example `post.encoders`.
@hunse
Copy link
Collaborator Author

hunse commented Jun 19, 2015

Okay, this is rebased and ready for review.

The removing 'decoders' from BuiltConnection is optional; we can discuss if we want to do this or not.

@arvoelke
Copy link
Contributor

I had been using PES assuming that the error is w.r.t. the decoded vector of dimension size_mid, not the transformed vector of dimension size_out. That's how it worked before, but we had no unit tests to assert this behaviour (so I guess I had been taking advantage of undefined behaviour). The old behaviour seemed natural to me (e.g. projecting a learned scalar to each dimension in a product network), but they are equivalent.

I've added a unit test to assert the new behaviour here (and fixed a line to make it pass): 91d59a3

Note: if you change line 173 to have no transform, then that's what would have passed on master. Feel free to cherry-pick this in if we're in agreement.

I'll take a look at the rest soon.



def get_sliced_signal(signal, s, model):
assert signal.ndim == 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Rename to sliced_signal to be consistent with filtered_signal, and since get usually implies no side-effects
  • Docstring
  • Change assertion to exception

@arvoelke
Copy link
Contributor

Gone over it pretty carefully and it looks good and well thought out. I'm fine with the renaming to weights, but regardless this all seems important enough to warrant the all-important changelog entry (especially since this altered a bunch of our examples, and therefore our documentation).

@hunse
Copy link
Collaborator Author

hunse commented Jun 22, 2015

One thing to note is that with this PR, we no longer use full_transform. Should we remove it? This would affect #754 and #755.

@hunse
Copy link
Collaborator Author

hunse commented Jun 22, 2015

Addressed @arvoelke's suggestions. I kept the asserts in, because I think they should only ever be seen if we mess something up (i.e., users should never see them).

I also added a commit to remove the as_update argument from the Copy and DotInc operators, since it was unused in both cases.

@arvoelke
Copy link
Contributor

Cherry-pick 91d59a3 and update the change log? Then it looks good to me.

@arvoelke
Copy link
Contributor

arvoelke commented Jul 2, 2015

LGTM. Would be good for someone else to look this over now and get it in soon as it's a pretty big change.

@tbekolay
Copy link
Member

tbekolay commented Jul 2, 2015

I'll give this a review tonight or early tomorrow!

@tbekolay
Copy link
Member

tbekolay commented Jul 3, 2015

OK, reviewed! This looks great to me. Only a few issues, some of which I can do during the merge.

  1. As commented inline, are you sure we need to remove decoders from BuiltConnection? I know Chris used this for a learning notebook recently...
  2. Is it still possible to probe 'decoders' and 'transform'? If so, then I think we should allow this, but raise a deprecation warning and remove that ability in 2.2. If not, then perhaps we should allow this for now with the deprecation warning? In either case, we need a stronger changelog message, as it means end users will need to change their models (I can write this in the merge though).

I'll aim to merge this in today.

@hunse
Copy link
Collaborator Author

hunse commented Jul 3, 2015

My rationale for removing "decoders" from BuiltConnection was that it would be pretty rare for someone to want the decoders without the transform in it. I've started thinking about the "transform" and "function" on connections as going hand in hand (in fact, there's an argument that we shouldn't really even have "transform" on an ensemble->ensemble connection, because you can always build it in to "function", but let's not go there now since it makes problems for other connection types). Anyway, if you want the decoders for the "function" that your connection is computing, I think it makes the most sense if that includes the transform as well, since the transform is also part of the "function" you're computing.

As for probing "decoders" and "transform", it's not possible to probe them in the way you could before, which is why I chose "weights" as the name for the new matrix. That way, whether we're talking about BuiltConnection or probing, it's clear that "weights" is different from the old "transform" or "decoders". It would be good to have some error notifying users that "decoders" and "transform" are obsolete, if users try to probe them, but I can't think of any sensible way to map them to what's there now (mapping both "transform" and "decoders" to "weights" would cause problems, I think, because probes would appear to continue working but not return what they used to).

@tbekolay
Copy link
Member

Makes sense @hunse! I was working on adding a more helpful error message for when you try to probe decoders / transform, but it kind of became its own beast (see #781) so I'm happy to merge this as is. I'll give this a final lookover and history fixup tomorrow morning and then merge.

hunse and others added 3 commits July 13, 2015 14:00
Rather than storing `decoders` and `transform` separately
in the simulated connection, they're now combined into `weights`.
This simplifies the connection builder code, as well as the
learning rule code.

This requires removing 'decoders' from BuiltConnection,
as 'weights' has both the 'decoders' and 'transform' combined.
I removed it to reduce confusion from 'decoders' returning something
different from before.

I also added a `SlicedCopy` operator to allow for better
post slicing, such as slicing post neurons.
Future work includes better pre slicing too.

Additionally, connection input slicing was improved.
It now works with Neurons, and should make things easier in Nengo OCL.

In order to pass tests, I also made the following changes:

- Fixed examples to probe 'weights'.
- Fixed some of the tests.
- Cleaned up the connection builder a bit more and made it work
  with slices on weight solvers.
Also removed an old Simulator test that tested signal slicing with
raw operators, and should be well-covered by other tests.
@tbekolay
Copy link
Member

Fixed up history. Squashed the 'removing decoders from BuiltConnection' commit into the main one, as without it most models won't build. Merging in a few minutes unless there are last minute objections!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants