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

Updated Process interface #652

Merged
merged 10 commits into from
May 15, 2015
Merged

Updated Process interface #652

merged 10 commits into from
May 15, 2015

Conversation

hunse
Copy link
Collaborator

@hunse hunse commented Feb 11, 2015

As discussed in #622. See the first commit message for a summary of changes (there are a number).

The second commit fixes up the simulator reset so that it resets Processes.

For discussion, there are a number of name changes, so I want to make sure everyone is okay with those. Also, I wasn't sure whether we should try to "deprecate" the old StochasticProcess.f function so that 2.0 code can still run. I don't think it's quite as easy as just having that function return a reference to the process itself, so I would probably not bother with it.

@tcstewar
Copy link
Contributor

Hmm, I'm not going to get a chance to look at this in detail until the weekend, but just to check, why did you end up going with the PythonClosure-state approach rather than the PythonClass-state approach? I'd thought that's where the consensus was after the #622 discussion. Also, why doesn't the step function take t as an input? Isn't that necessary if it's run on a Simulator that doesn't guarantee a dt?

One thing to keep in mind is that we don't have to merge Process and NodeOutput. If they do turn out to be close enough to be the same thing, then that can simplify things, but if there are particular reasons that the Process implementation you're proposing differs from the desired NodeOutput stuff, then we should keep them separate. I still think they're pretty close, but I'm not as familiar with the inner workings of the Process stuff.

@hunse
Copy link
Collaborator Author

hunse commented Feb 12, 2015

why did you end up going with the PythonClosure-state approach rather than the PythonClass-state approach? I'd thought that's where the consensus was after the #622 discussion.

I think you're right, we were leaning towards the PythonClass-state approach. I had actually forgotten that when I did it, and the closure approach is also what the synapse classes use, so there's a nice parallel there.

Also, why doesn't the step function take t as an input? Isn't that necessary if it's run on a Simulator that doesn't guarantee a dt?

Yes, I guess we should add that.

One thing to keep in mind is that we don't have to merge Process and NodeOutput.

Very true. I did this PR based on what seemed to make sense for the existing Processes, without thinking much about how people might like to use them as node outputs. As it stands, what I have here should be quite powerful for doing various types of node outputs. But maybe we want a different interface; we could take the class approach for NodeOutputs, and the closure approach for Processes.

@s72sue
Copy link
Contributor

s72sue commented May 13, 2015

I was wondering when this will be reviewed and whether the Process interface in nengo2 is going to be updated? I need this interface to translate the HBB tutorials from nengo1.4 to nengo2.

@tcstewar
Copy link
Contributor

I was wondering when this will be reviewed and whether the Process interface in nengo2 is going to be updated? I need this interface to translate the HBB tutorials from nengo1.4 to nengo2.

This will get reviewed eventually, but things are still up in the air about the approach we will take. The PythonClosure approach is surprising to novice programmers, and the PythonClass approach is surprising to experienced programmers. I'm still hoping for a clear winner one way or the other.

That said, it shouldn't be necessary for translating the HBB tutorials, as the WhiteNoise object still works as it is. Once this PR gets sorted out, we should be able to clean up the tutorial a bit, but it should work fine without it (unless I'm not understanding the problem).

@hunse
Copy link
Collaborator Author

hunse commented May 13, 2015

The problem is, @s72sue needs actual white noise for the tutorials, to inject to neuron currents. This is something that I added in this PR.

In my opinion, we should go ahead and review and merge this, even if it's not the approach we ultimately want to take. I think it's considerably better than what we have now, and the user-facing side will look the same even if we later add a commit to change to the class approach (of course, if users have written their own processes, those would have to change, but we would have this resolved before 2.1 either way, so users would never have to see the intermediary step).

That said, I'm happy to split out parts of this commit if we really want to wait to decide. I'm just getting a little frustrated with some of my PRs sitting around for a long time, and getting stale, and then having to be rebased again, as well as not being able to use the improvements in further PRs and projects, etc.

@tcstewar
Copy link
Contributor

Yes, if this is causing frustration with how long it's taking, then we should definitely move ahead and sort something out with it quickly. I'd taken the lack of discussion on this thread as an indication that it wasn't a high priority for anyone, and then lots of other things came up.

Can we meet tomorrow (thursday) in person and talk it through? Basically, I want to get a clear understanding on what people making their own processes and what backend developers need to know about this system. I definitely agree that it's be good to get something merged in soon, but I also think we need to be clear on what this means for backends too (both in terms is supporting Processes as noise input to neurons and in terms of supporting custom Processes as part of Nodes, if we want to keep that part).

@tbekolay
Copy link
Member

I'm available tomorrow to talk about it. Whenever!

@hunse
Copy link
Collaborator Author

hunse commented May 14, 2015

@tcstewar and I were thinking 10:00 am.
On May 13, 2015 8:21 PM, "Trevor Bekolay" notifications@github.com wrote:

I'm available tomorrow to talk about it. Whenever!


Reply to this email directly or view it on GitHub
#652 (comment).

@tbekolay
Copy link
Member

Kay, sounds good.

@hunse
Copy link
Collaborator Author

hunse commented May 14, 2015

Okay, rebased and ready for review.

This is more descriptive of its actual function, and lets us have a
DistributionParam that just does distributions. Also moved these
params to `dists.py`.
@hunse hunse force-pushed the processes branch 2 times, most recently from 6deb2db to 8c56f7d Compare May 14, 2015 20:36
@hunse
Copy link
Collaborator Author

hunse commented May 14, 2015

Okay, made those changes! They took a little longer than I thought, but I figured out that WhiteSignal is actually naturally periodic (some weird Fourier stuff going on), so we don't need to do all that reflection magic, we can just loop through it periodically. This means that I'm less unhappy with the WhiteSignal now. I renamed duration to period, and if users pick a period that is shorter than their simulation it just means the signal will start to repeat, but nice and continuously so it should look okay.

EDIT: The changes were

  1. Adding back in the DistOrArrayParam tests that I accidentally removed during the previous rebase.
  2. Commenting the WhiteSignal step function, which was no longer necessary since we don't do reflection.
  3. Flake8 errors fixed.

@celiasmith
Copy link
Contributor

Is white allowing different kinds of white (e.g. Gaussian/Uniform?)

Eric Hunsberger wrote:

Okay, made those changes! They took a little longer than I thought,
but I figured out that WhiteSignal is actually naturally periodic
(some weird Fourier stuff going on), so we don't need to do all that
reflection magic, we can just loop through it periodically. This means
that I'm less unhappy with the WhiteSignal now. I renamed |duration|
to |period|, and if users pick a period that is shorter than their
simulation it just means the signal will start to repeat, but nice and
continuously so it should look okay.


Reply to this email directly or view it on GitHub
#652 (comment).

@hunse
Copy link
Collaborator Author

hunse commented May 14, 2015

WhiteNoise allows for different distributions (Gaussian, Uniform, etc., even UniformHypersphere). WhiteSignal, though, is the one that we generate in the Fourier domain, and I've never quite figured out the relationship between different white noise distributions and how they appear in the Fourier domain.

@hunse
Copy link
Collaborator Author

hunse commented May 14, 2015

Okay, added another test to make sure things stay deterministic in Travis CI. I think this is ready to go, fingers crossed.

@tbekolay
Copy link
Member

Cool, will quickly re-review and presumably merge this evening or early tomorrow morning.

@tcstewar
Copy link
Contributor

Looking good to me.

As a note to those following this discussion, the intent here is to get this merged in as it greatly improves the ability to control and generate noise in models. Right now, it also allows you to attach these noise Processes to a Node and use it for generating signals. The API for doing this is still a work in progress, and this PR is meant as a stepping stone in that direction.

One thing to keep in mind is that we should NOT do an official release until we get the Node part of this sorted out. But this PR looks good to me as a step in the right direction.

@tbekolay
Copy link
Member

That reminds me actually, one thing that's missing is a changelog entry. It's a user-facing change so we should make one (or multiple in this PR's case) even if, before the release, we have the change or replace one of those entries.

I'll add them in the merge if they don't magically appear before I review / merge 🌈

@hunse
Copy link
Collaborator Author

hunse commented May 15, 2015

What's our general policy on the changelog? Is it the author's job or the merger's job to write it? I think we had said at one point it's the merger's job, but I think it makes more sense if the author does it, just so we have two pairs of eyes look at it just like everything else. My problem is I always forget.

@hunse hunse force-pushed the processes branch 2 times, most recently from f583102 to 3484698 Compare May 15, 2015 03:06
@hunse
Copy link
Collaborator Author

hunse commented May 15, 2015

Okay, added changelog entries, and also referenced #582 in the commit message of 1d040f0.

@jgosmann
Copy link
Collaborator

WhiteSignal, though, is the one that we generate in the Fourier domain, and I've never quite figured out the relationship between different white noise distributions and how they appear in the Fourier domain.

From what I learned from Wikipedia it's a special property of Gaussian white noise vectors that they stay Gaussian white noise vectors under orthogonal transformations. That would mean the generation in the Fourier transform is probably only possible for Gaussian white noise.

@hunse
Copy link
Collaborator Author

hunse commented May 15, 2015

That would mean the generation in the Fourier transform is probably only possible for Gaussian white noise.

But you can generate for example a uniform white noise signal and take the Fourier transform and get something, so it seems to me that there must be something in the frequency domain that unites all uniform white noise signals and makes them different from Gaussian white noise. That relationship could be quite complicated, though. Also, I'm not sure if this is at all useful to people practically, so I wouldn't worry too much about it. But it is an interesting question.

hunse added 2 commits May 15, 2015 09:17
Removed `build_pyfunc`, since it is easier just to make a SimPyFunc.
Also added LinearFilterParam, specific to LinearFilters, for use
in future Processes.
@tbekolay
Copy link
Member

This looks awesome! Made one FIXUP commit to not use mutable object as default args (see 6fd3682). Also made an issue to possibly make these immutable in the future (#719). @hunse LMK if the FIXUP commit looks good; if so I'll fixup and merge!

@hunse
Copy link
Collaborator Author

hunse commented May 15, 2015

Looks good. Having immutable objects would definitely be nice.

hunse added 6 commits May 15, 2015 10:56
Renamed StochasticProcess to Process (since it is now more general),
and updated the interface as per discussion in #622.

Other changes:
- Renamed `WhiteNoise` to `WhiteSignal`, since (a) it is band-limited
  and thus "colored" not "white" noise, and (b) this name is a better
  reflection of how we use it, as a signal, not as noise.
It turns out the signal generated by WhiteSignal is actually
periodic! This means we don't have to reflect it. I added a test
to check that this periodicity works (i.e. it and its first
derivative are continuous).
The simulator now re-makes all `step` functions on a reset, which
should reset all operators. Fixes #616.

The simulator seed (currently only used by Processes, I think) can
be changed when calling `Simulator.reset`. Fixes #582.
Specifically, we're worried about examples in .ipynb_checkpoints
directories, but we might as well ignore all hidden directories.
This ensures that these tests are deterministic.

Also, `utils/tests/test_neurons.py:test_rates_kernel` would
occasionally fail in Travis CI (only occasionally because the
simulator seed wasn't set!), so I relaxed the tolerance a bit.
One entry for the Process API changes, and one for
Processes being reset by the Simulator.
@tbekolay tbekolay merged commit 4742df9 into master May 15, 2015
@tbekolay tbekolay deleted the processes branch May 15, 2015 15:05
@s72sue
Copy link
Contributor

s72sue commented May 18, 2015

Hey Eric,

I was wondering how I can generate a uniform white noise i.e., chosen
uniformly from (-10, 10) ? Based on what you are saying it seems that I
need to use WhiteNoise for this. But looking at the code, it looks like I
should be using WhiteSignal with a period of 20 and high=10.

Can you please clarify?

-Sue

On Thu, May 14, 2015 at 5:19 PM, Eric Hunsberger notifications@github.com
wrote:

WhiteNoise allows for different distributions (Gaussian, Uniform, etc.,
even UniformHypersphere). WhiteSignal, though, is the one that we generate
in the Fourier domain, and I've never quite figured out the relationship
between different white noise distributions and how they appear in the
Fourier domain.


Reply to this email directly or view it on GitHub
#652 (comment).

@hunse
Copy link
Collaborator Author

hunse commented May 18, 2015

No, you definitely want WhiteNoise. Something like nengo.processes.WhiteNoise(dist=nengo.dists.Uniform(-10, 10)). You might have to play around with the amplitude, though, to get the results to be reasonable/simiar to Nengo 1.4. You want the range of your noise to be on the same order of magnitude as the signal you're adding it to. In your case, you're adding it to the neuron input current, so you probably want a range of [-1, 1] or even a bit smaller.

@s72sue
Copy link
Contributor

s72sue commented May 18, 2015

hmm..okay, thanks.

On Mon, May 18, 2015 at 3:10 PM, Eric Hunsberger notifications@github.com
wrote:

No, you definitely want WhiteNoise. Something like nengo.processes.WhiteNoise(dist=nengo.dists.Uniform(-10,
10)). You might have to play around with the amplitude, though, to get
the results to be reasonable/simiar to Nengo 1.4. You want the range of
your noise to be on the same order of magnitude as the signal you're adding
it to. In your case, you're adding it to the neuron input current, so you
probably want a range of [-1, 1] or even a bit smaller.


Reply to this email directly or view it on GitHub
#652 (comment).

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

6 participants