[pymvpa] tiny suggestion for SOM (10 second change)

Nick Oosterhof nikolaas.oosterhof at unitn.it
Mon Mar 11 12:30:03 UTC 2013


On 10 March 2013 23:47, Ike Hall <ike.hall at gmail.com> wrote:
> It would appear that the SimpleSOMMapper class performs the initialization
> of it's Kohonen layer in the SimpleSOMMapper._train method.  As the .train()
> method calls ._pretrain, ._train, and ._posttrain in order, I submit that it
> would be preferable to move the initialization phase to ._pretrain.  With
> this change, if one wants to subclass the SimpleSOMMapper to use some other
> initialization, they only need to override ._pretrain rather than _train.

As far as I can see currently there are three lines of code in the
initalization phase:

self._K = np.random.standard_normal(tuple(self.kshape) + (samples.shape[1],))
unit_deltas = np.zeros(self._K.shape, dtype='float')
dqd = np.fromfunction(lambda x, y: (x**2 + y**2)**0.5, self.kshape,
dtype='float')

and I am not convinced that it would be sensible to move the last two
to a separate _pretrain (the variables would have to be stored in self
and it all gets a bit messy). That leaves a single line that could
move to _pretrain - is that really worth it?

Or do you have other suggestions on what to move to _pretrain?



More information about the Pkg-ExpPsy-PyMVPA mailing list