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

Introduce new submodels machinery #571

Closed Tobias-Fischer closed 10 years ago

Tobias-Fischer commented 10 years ago

This pull request introduces a new machinery to define models. They can be summarized as follows:

  1. ty files typically just import a submodel, call the setup() method, if needed change some of the parameters and then instantiate the model by calling the model instance.
  2. A deferred instantiation of models is now possible. By calling the setup() method of a submodel, only templates for sheets and projections are created. These templates (SheetRef and ProjectionRef) contain an attribute parameters which is then passed to the actual sheet/projection once the submodel instance is called. SheetRef and ProjectionRef both implement a resolve() method which returns the actual sheet/projection after instantiation. This might be used by Collector.
  3. The SheetRef class also has an attribute identifier. This is a dict specifying the sheet more detailed than just the name. E.g. the identifier might be {'eye':'Left','layer':'LGN','polarity':'On'}. The class then overrides the str() method to return a string based on this identifier matching the names of sheets which have been used in previous models.
  4. The base class for all submodels is SensoryModel. This is an abstract class which provides the structure for the new machinery of setting up models. VisualInputModel is a subclass of SensoryModel, specifying the training patterns of a submodel. EarlyVisionModel is a subclass of VisualInputModel, specifying the retina and LGN sheets. It supports multiple eyes as well as multiple spatial frequency sheets. ColorEarlyVisionModel is a subclass of EarlyVisionModel, and extends it to support color sheets. This class is experimental so far!
  5. ModelGCAL is a subclass of ColorEarlyVisionModel (but can be changed without affecting any results to EarlyVisionModel), and specifies V1 according to examples/gcal.ty. Furthermore, it allows multiple lagged projections from LGN sheets to V1 as a motion model.

Submodels lack of more documentation, which will be added soon (see TODO's).

This pull request depends on https://github.com/ioam/topographica/pull/570, https://github.com/ioam/imagen/pull/30 and https://github.com/ioam/featuremapper/pull/10

jlstevens commented 10 years ago

I would like to see this PR updated with the new decorator stuff - even if there still some kinks to work out. At least we can then all discuss a particular version of the code together!

jlstevens commented 10 years ago

Ok great!

If it works, I'm happy to merge now and work out the remaining details later.

jlstevens commented 10 years ago

Now it is merged, Philipp and I are just going to make changes we think are sensible on master. Do object if there is something that won't work properly (we will test the example gcal file).

jbednar commented 10 years ago

Ok, good. I've added my proposed support for moving global_params handling out of the .ty file, and it seems to work fine and so I've pushed it. Please make sure to pull before making your own edits, and to check whether you see any problems with my latest additions.

jbednar commented 10 years ago

BTW, we need a new name for gcal_usingsubmodel.ty or gcal.ty. I'd like to keep gcal.ty around as an example of how to specify a model independently of all other models, illustrating the basic procedure but not used much in practice. Maybe change gcal.ty to gcal_or.ty (since it's hard-coded to work only for orientation), and then change gcal_usingsubmodel.ty into gcal.ty? If so, maybe best to hold off a bit from this change, until submodels have settled down a bit, before we use them for everything ever.

jlstevens commented 10 years ago

I've made a whole load of changes. I'll try to reopen this pull request so we can discuss the submodels machinery here - not because I am unhappy with the merge!

Edit 1: Apparently you cannot re-open a pull request like this. I just hope you will notice any new comments I post here.

Edit 2: I think it is more appropriate to use GittHub Issues to discuss this system now that it has been merged so I have created a new issue (#573) where we can discuss this.