ctn-archive / nengo_theano

ABANDONED; see https://github.com/nengo/nengo instead
MIT License
3 stars 3 forks source link

Specifiying dt at build time / run time? #31

Closed xchoo closed 11 years ago

xchoo commented 11 years ago

There is currently no way of specifying the simulation dt at runtime for the theano implementation. Nor is it possible to set the dt of the simulation at build time (it is fixed to 1ms at the ensemble level, and the network didn't pass on this parameter to it).

I think there has to be some discussion as to what we want to support in the API. Should we allow the ability to set the dt at runtime (as it is possible in Nengo, but not in Theano), or do we want to restrict it to be settable only at build time?

tcstewar commented 11 years ago

Yup, this is a bit of a mess. Right now there are I think two different dt parameters: one for the Network (which tells it how many times to call tick() if you want to move the simulation forward by time seconds), and one for Neuron (which is used for the neuron dynamics). Oh, and one for terminations to do the pstc. All of these right now are just fixed at 0.001.

Right now in nef-java, we can specify dt on the run command. This lets us do this:

net.run(10, dt=0.0001)

and also lets us do weird things like this, where we change dt while the model is running:

dt=0.0001
while net.run_time<10:
   net.run(1, dt)
   dt+=0.0001

So, right now the API supports changing dt on the fly, which is why dt is a parameter on the run() command, rather than on the Network itself.

My feeling is that a) I've never wanted to change dt while a model is running, and b) I think that would be annoying to implement in the theano version. So I'd lean towards adjusting the API so that dt is specified when creating the Network (or perhaps something weird like "you can only specify dt the first time you call run"), and then fix the theano code so that it actually does let you do that (Xuan already has that change implemented).

studywolf commented 11 years ago

So, does anyone have the actual recent code? I changed this like 2 weeks ago to be a runtime thing. dt is no longer specified during build...this was already an issue. dt is now passed to all the update() methods.

That said it appears there's an issue filtering when the timestep is not .001, I'll look into that.

xchoo commented 11 years ago

Oh. My bad.. I'm still running off my benchmarking branch of the code. That said, Terry did bring up the point that allowing dt to be changeable at runtime might affect the way (speed) theano runs? I don't know the inner workings of theano so I cannot attest to that fact.

I am going to close this issue, but the current (Travis) implementation should be more closely examined to ensure minimal impact on the runtime in theano.

studywolf commented 11 years ago

And now it's completely working! I'll update as soon as I get permissions again,... and then you should update too...@xchoo

tcstewar commented 11 years ago

Btw, Travis' approach ended up being to have dt specified on the Network constructor -- the deciding factor was that we need dt when computing the decoders (since neurons behave differently with different dt values). This somewhat fits with the approach of computing decoders based on actual neuron behaviour, rather than the rate mode approximation.

studywolf commented 11 years ago

Right! So it's passed in to the ensembles when origins are being generated, and then it's passed in to all the object's update() function when the theano graph is built.