def gaussian(c, sigma): """Returns a Gaussian centered in c.""" d = 2*pi*sigma*sigma ax = exp(-power(neigx-c[0], 2)/d) ay = exp(-power(neigy-c[1], 2)/d) return outer(ax, ay) # the external product gives a matrix out = gaussian((2,2),1)当选sigma设为1时,所有的节点都有一定的更新幅度,中心优胜节点是1,越远离优胜节点,更新幅度越低,sigma其实是在控制这种随距离衰退的程度当sigma取值很小时,只有优胜节点更新幅度是1,其余几乎都接近0当sigma取值较大时,衰退的程度很慢,即使是边缘的节点,也有较大的更新幅度
def bubble( c, sigma): """Constant function centered in c with spread sigma. sigma should be an odd value. """ ax = logical_and(neigx > c[0]-sigma, neigx < c[0]+sigma) ay = logical_and(neigy > c[1]-sigma, neigy < c[1]+sigma) return outer(ax, ay)*1. out = bubble((2,2),sigma= 1.5)图中可以看出,中心为优胜节点,当sigma=1.5时,周围一圈的节点都处于优胜邻域中且它们的更新幅度相同,都等于1
三种初始化方法:1. Random initialization:适用于对输入数据有很少或没有任何先验知识 2. Initialization using initial samples:优点是初始时刻,网络节点就与输入数据的拓扑结构很相似 4. Linear initialization(PCA):让网络向输入数据能力最大的方向延伸其实在miniSom创建模型后,就已经进行Random initialization了;som.random_weights_init()其实是"Initialization using initial samples"起初我以为这个是Random initialization....Principal component initialization is preferable (in dimension one) if the principal curve approximating the dataset can be univalently and linearly projected on the first principal component (quasilinear sets). For nonlinear datasets, however, random initiation performs better.很多论文做过实验,PCA Initialization并不是在任何情况下都优于 random initiation,取决于输入数据本身的性质。推荐调参的时候,两种都试试吧~