Exemplo n.º 1
0
    def _train(self, t):
        sample = self._samples[t]

        # bmu
        bmu_id = self._bmu(sample)
        bmu_position = self._positions[bmu_id]

        # update weight
        D = normVectors(self._positions - bmu_position)
        L = self._learningRestraint(t)
        T = self._neighborhoodFunction(t, D)

        # update nodes
        for ci in range(3):
            self._nodes[:, ci] += L * T * (sample[ci] - self._nodes[:, ci])
Exemplo n.º 2
0
    def _train(self, t):
        sample = self._samples[t % len(self._samples)]
        # print sample
        # bmu
        bmu_id = self._bmu(sample)
        bmu_position = self._positions[bmu_id]
        #在一维度情况下 bmu_id 和 bmu_position相等

        # update weight
        D = normVectors(self._positions - bmu_position)
        # L是一个从0.16逐渐减小的数值
        L = self._learningRestraint(t)
        # T是一个根据D计算出来的影响范围
        T = self._neighborhoodFunction(t, D)

        # update nodes
        # print self._nodes
        for ci in range(3):
            self._nodes[:, ci] += L * T * (sample[ci] - self._nodes[:, ci])
Exemplo n.º 3
0
 def _bmu(self, sample):
     norms = normVectors(self._nodes - sample)
     bmu_id = np.argmin(norms)
     return bmu_id
Exemplo n.º 4
0
 def _bmu(self, sample):
     norms = normVectors(self._nodes - sample)
     bmu_id = np.argmin(norms)
     return bmu_id