Code Monkey home page Code Monkey logo

Comments (6)

tnowotny avatar tnowotny commented on August 15, 2024

Random number generators rand() and randn() are now working as expected I believe. Subject to more testing.
BinomialFunction could also be done but I am unsure about where to put the code. So far BinomialFunction is defined in brian2.input.binomial. If I just ad the genn implementation there alongside the other implementations (in the BinomialFunction.init function) that would work but introduce a dependency of Brian2 on Brian2GeNN. That's probably not what we want. But how else to add the genn implementation? Do you have a view how one would best add additional implementations for BinomialFunction @mstimberg ?

from brian2genn.

mstimberg avatar mstimberg commented on August 15, 2024

I don't see any good way to make this work at the moment, unfortunately. I filed an issue for it, it should only need a bit of refactoring in Brian2 : brian-team/brian2#542.

As a short term solution you could add a GeNNBinomialFunction class, but of course that will not be automatically used by PoissonInput. But then again, PoissonInput is just a convenience wrapper around creating a binomial function object and calling a run_regularly operation on the group with target_var += binomial()*weight.

from brian2genn.

tnowotny avatar tnowotny commented on August 15, 2024

If BinomialFunction implementations were hanging around in something like DEFAULT_FUNCTIONS then it would be very easy.

from brian2genn.

mstimberg avatar mstimberg commented on August 15, 2024

The problem is that there's not one implementation as for other functions. You use BinomialFunction like:

binomial = BinomialFunction(n=1000, p=0.01)
G = NeuronGroup(...)
G.run_regularly('v += binomial()*0.1')

From Brian's point of view, each BinomialFunction instance will be a separate function with separate implementation. But it's not terribly complicated, after the refactoring for brian-team/brian2#542 you'll have to do something like:

def genn_code_for_binomial(n, p, use_approximation=True):
    # ...

BinomialFunction.code_generators[GeNNCodeObject] = genn_code_for_binomial

from brian2genn.

tnowotny avatar tnowotny commented on August 15, 2024

Oh - I see: The different n and p. What you propose sounds like a good plan. I will have the code ready once this is done.

from brian2genn.

tnowotny avatar tnowotny commented on August 15, 2024

Binomial function now working I believe. Moving on.

from brian2genn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.