ioam / topographica

A general-purpose neural simulator focusing on topographic maps.
topographica.org
BSD 3-Clause "New" or "Revised" License
53 stars 32 forks source link

How to set input seeds in GCAL collector ? #699

Closed dancehours closed 3 years ago

dancehours commented 3 years ago

Dear Prof. Bednar,

I am using the model by GCAL collector and I need to change the input seeds for different orientation maps. But in the submodel gcal.py and earlyvision.py there are not parameters for input seeds. I can set the seeds in patterncoordinator.py. But it is not convenient to launch multiple jobs by one time. So I would like to ask, how to set the input seeds in the submodel GCAL used by the collecotr ? I guess I need to import patterncoordinator there, but I am not sure how to set it exactly.

jbednar commented 3 years ago

Good question. In a quick glance over the files I don't see where to configure the input seeds when using gcal.ty and don't recall how to do that. Seems like there ought to be a better way, but you should be able to control seeds globally using something like import numbergen as ng ; ng.RandomDistribution.seed=2, and probably something similar for patterncoordinator that would apply only to input patterns. I'm not sure how that would affect launching multiple jobs, seems like you can do anything like this for multiple jobs easily enough...

dancehours commented 3 years ago

Hi Bednar, I tried "import numbergen as ng ; ng.RandomDistribution.seed=2" but it doesn't effect the retina input differences. I think I can just import patterncoordinator.master_seed to the model GCAL's definition and then change the seed. It seems to work and produce different input patterns set, but I am not quite sure if this way gives problems.

jbednar commented 3 years ago

Sounds like the RandomDistribution default seed is being overridden by the PatternCoordinator's master_seed, so setting it at the master_seed sounds like the right thing to do. Good work!

dancehours commented 3 years ago

I tried to set the input_seed as a parameter to give to the ModelGCAL so that I can launch multiple jobs, but I meet an error: topo.sim.model = ModelGCAL(PatternCoordinator.master_seed=int(args.input_seed)) SyntaxError: keyword can't be an expression I would like to ask how to solve this ?

jbednar commented 3 years ago

As the message indicates, a keyword cannot be an expression like PatternCoordinator.master_seed. In the constructor for one object you are not allowed to set attributes on arbitrary other objects like that. Instead you'd do it separately:

PatternCoordinator.master_seed=int(args.input_seed)
topo.sim.model = ModelGCAL()

If you wanted to do it in the model's constructor you'd have to subclass ModelGCAL with your own class, add an input_seed parameter to that class, have its constructor set PatternCoordinator's seed from that value, and instantiate your new class instead of ModelGCAL. It's a bit rude of a class to set a class parameter in some other class like that, but it would then make what you're doing work as you have it...