|
@@ 482-486 (lines=5) @@
|
| 479 |
|
|
| 480 |
|
for neighbor_index in self._neighbors[index]:
|
| 481 |
|
distance = self._sqrt_distances[index][neighbor_index]
|
| 482 |
|
if (distance < self._local_radius):
|
| 483 |
|
influence = math.exp( -( distance / (2.0 * self._local_radius) ) );
|
| 484 |
|
|
| 485 |
|
for i in range(dimension):
|
| 486 |
|
self._weights[neighbor_index][i] = self._weights[neighbor_index][i] + self._learn_rate * influence * (x[i] - self._weights[neighbor_index][i]);
|
| 487 |
|
|
| 488 |
|
|
| 489 |
|
def train(self, data, epochs, autostop = False):
|
|
@@ 470-474 (lines=5) @@
|
| 467 |
|
for neuron_index in range(self._size):
|
| 468 |
|
distance = self._sqrt_distances[index][neuron_index];
|
| 469 |
|
|
| 470 |
|
if (distance < self._local_radius):
|
| 471 |
|
influence = math.exp( -( distance / (2.0 * self._local_radius) ) );
|
| 472 |
|
|
| 473 |
|
for i in range(dimension):
|
| 474 |
|
self._weights[neuron_index][i] = self._weights[neuron_index][i] + self._learn_rate * influence * (x[i] - self._weights[neuron_index][i]);
|
| 475 |
|
|
| 476 |
|
else:
|
| 477 |
|
for i in range(dimension):
|