<div dir="ltr">> On 10 March 2013 23:47, Ike Hall <<a href="mailto:ike.hall@gmail.com">ike.hall@gmail.com</a>> wrote:<br>
>> It would appear that the SimpleSOMMapper class performs the initialization<br>
>> of it's Kohonen layer in the SimpleSOMMapper._train method.  As the .train()<br>
>> method calls ._pretrain, ._train, and ._posttrain in order, I submit that it<br>
>> would be preferable to move the initialization phase to ._pretrain.  With<br>
>> this change, if one wants to subclass the SimpleSOMMapper to use some other<br>
>> initialization, they only need to override ._pretrain rather than _train.<br>
><br>
> As far as I can see currently there are three lines of code in the<br>
> initalization phase:<br>
><br>
> self._K = np.random.standard_normal(<div id=":85">tuple(self.kshape) + (samples.shape[1],))<br>
> unit_deltas = np.zeros(self._K.shape, dtype='float')<br>
> dqd = np.fromfunction(lambda x, y: (x**2 + y**2)**0.5, self.kshape,<br>
> dtype='float')<br>
><br>
> and I am not convinced that it would be sensible to move the last two<br>
> to a separate _pretrain (the variables would have to be stored in self<br>
> and it all gets a bit messy). That leaves a single line that could<br>
> move to _pretrain - is that really worth it?<br>
><br>
> Or do you have other suggestions on what to move to _pretrain?<br>
><br><br></div><div id=":85">...forgot to send to the list:<br><div><div>Currently I have just moved the first line to _pretrain as I 
would like to subclass this class to use an alternative initialization 
of just self._K, and don't want to override the entirety of _train.  As I
 see it, the second line should remain in _train, and the third could go
 either way. If I were designing the class, personally I would make the 
choice to store dqd in self, and define it at __init__ level requiring 
an extra parameter for the distance function that defaults to the 
euclidian distance.  (I have seen some implementations that use the 
manhattan distance rather than euclidian distance).  In my opinion, it's
 a judgement call whether you think the distance formula on self._K 
should be a property of the class, or a property of the training 
method.  <br>
<br></div><div>In summary:  Moving the first line to _pretrain is something I would strongly advocate.<br></div><div>moving
 dqd to be stored in self at initialization is something I would 
advocate for, but far less strongly, as someone wanting to use a 
different distance function would (likely?) also want to override the 
_compute_influence_kernel method, and at that point they are not far 
from overriding all of _train.<br>
</div><br></div>Cheers<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Mar 10, 2013 at 5:47 PM, Ike Hall <span dir="ltr"><<a href="mailto:ike.hall@gmail.com" target="_blank">ike.hall@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">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.<span class="HOEnZb"><font color="#888888"><div>

<br></div><div>--Ike Hall</div></font></span></div>
</blockquote></div><br></div>