|
@@ 542-546 (lines=5) @@
|
| 539 |
|
|
| 540 |
|
for neighbor_index in self._neighbors[index]:
|
| 541 |
|
distance = self._sqrt_distances[index][neighbor_index]
|
| 542 |
|
if (distance < self._local_radius):
|
| 543 |
|
influence = math.exp( -( distance / (2.0 * self._local_radius) ) );
|
| 544 |
|
|
| 545 |
|
for i in range(dimension):
|
| 546 |
|
self._weights[neighbor_index][i] = self._weights[neighbor_index][i] + self._learn_rate * influence * (x[i] - self._weights[neighbor_index][i]);
|
| 547 |
|
|
| 548 |
|
|
| 549 |
|
def train(self, data, epochs, autostop = False):
|
|
@@ 530-534 (lines=5) @@
|
| 527 |
|
for neuron_index in range(self._size):
|
| 528 |
|
distance = self._sqrt_distances[index][neuron_index];
|
| 529 |
|
|
| 530 |
|
if (distance < self._local_radius):
|
| 531 |
|
influence = math.exp( -( distance / (2.0 * self._local_radius) ) );
|
| 532 |
|
|
| 533 |
|
for i in range(dimension):
|
| 534 |
|
self._weights[neuron_index][i] = self._weights[neuron_index][i] + self._learn_rate * influence * (x[i] - self._weights[neuron_index][i]);
|
| 535 |
|
|
| 536 |
|
else:
|
| 537 |
|
for i in range(dimension):
|