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

Raise exception on invalid gains. #1248

Merged
merged 1 commit into from
Apr 18, 2017
Merged

Raise exception on invalid gains. #1248

merged 1 commit into from
Apr 18, 2017

Conversation

jgosmann
Copy link
Collaborator

Motivation and context:
As noted in #1212 (and #1231) intercepts >= 1 give unexpected results for most neuron types. The matter is however a bit more complicated as detailed in this comment. The correct generalization to all neuron types (in my opinion) is that non-positive gains give unexpected results. Thus, the core change of this PR is to check this and raise an exception when violated. There is a bunch of related changes, though:

  • As detailed in the linked comment, the gain and bias calculation for the sigmoid neurons was incorrect giving flipped tuning curves for max. firing rates below the firing rate of the inflection point. This calculation was fixed. The new gain formula is based on the fact that the firing rate at the inflection point has to be 1/2 of 1/tau_ref.
  • As also detailed in the linked comment, for max. firing rates below the firing rate of the inflection point, the intercept (i.e. inflection point) has to be > 1. The sigmoid inflection point was set to 250Hz while our default max_rates were 200 to 400Hz. Thus, depending on the sampled max_rates, the valid intercept range would switch. I propose with this PR to change sigmoid tau_ref to 0.0025 which brings the inflection point to 200Hz and the firing rate in the limit to 400Hz. This at least allows to use the sigmoid neuron type without an exception and changing any of the other ensemble defaults. But technically it is a breaking change! We could leave tau_ref at it's old value, but would likely need to adjust the max_rates in a lot of our tests.
  • Changing the tau_ref changed the sigmoid tuning curves which required to fix a few other tests.

Interactions with other PRs:
This PR supersedes #1243.

How has this been tested?
Added some tests for the sigmoid neuron and a test checking that invalid intercepts raise an exception.

How long should this take to review?

  • Average (neither quick nor lengthy)

Types of changes:

  • [Without the tau_ref change: Bug fix (non-breaking change which fixes an issue)]
  • Breaking change (fix or feature that causes existing functionality to change)

Checklist:

  • I have read the CONTRIBUTING.rst document.
  • I have updated the documentation accordingly. (Maybe some this comment should put somewhere in the documentation? Maybe we should add what intercepts are valid to the documentation of sigmoid neurons? In any case some feedback on the technical site of this PR would be nice before investing time in further documentation.)
  • I have included a changelog entry.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link
Contributor

@Seanny123 Seanny123 left a comment

Choose a reason for hiding this comment

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

LGTM, except for the error messages which I have a tendency of being too picky with.

@@ -95,6 +96,14 @@ def get_gain_bias(ens, rng=np.random):
max_rates = get_samples(ens.max_rates, ens.n_neurons, rng=rng)
intercepts = get_samples(ens.intercepts, ens.n_neurons, rng=rng)
gain, bias = ens.neuron_type.gain_bias(max_rates, intercepts)
if gain is not None and (
not np.all(np.isfinite(gain)) or np.any(gain <= 0.)):
raise BuildError(
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be useful to link to a discussion of this problem? Maybe a forum post with the delightful doodles you made?

@jgosmann
Copy link
Collaborator Author

jgosmann commented Apr 7, 2017

Can we get this PR merged soon?
I just ran into this sort of problem again and an early failure would have been nice.

Copy link
Member

@tbekolay tbekolay left a comment

Choose a reason for hiding this comment

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

Amended in some changelog entries. Will merge when CI finishes, unless someone has issues with the changelog.

This also requires fixing the calculation of gains and biases for
sigmoid neurons. Because the intercepts for sigmoid neurons are actually
not an intercept, but the inflection point, valid intercepts depend on
whether the max firing rate is below or above the inflection point.
This commit also adjusts the default refractory time constant of the
sigmoid neurons to play well with intercepts < 1 and max firing rates
between 200 and 400Hz. This required some slight adjustments to tests.

Fixes #1212.
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