You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hallo, I am trying to understand your syntax for som implementation form scratch. I found something is not right.
for i in range(n_iterations):
# select a training example at random
t = data[:, np.random.randint(0, n)].reshape(np.array([m, 1]))
# find its Best Matching Unit
bmu, bmu_idx = find_bmu(t, net, m)
# decay the SOM parameters
r = decay_radius(init_radius, i, time_constant)
l = decay_learning_rate(init_learning_rate, i, n_iterations)
# update weight vector to move closer to input
# and move its neighbours in 2-D vector space closer
for x in range(net.shape[0]):
for y in range(net.shape[1]):
w = net[x, y, :].reshape(m, 1)
w_dist = np.sum((np.array([x, y]) - bmu_idx) ** 2)
w_dist = np.sqrt(w_dist)
if w_dist <= r:
# calculate the degree of influence (based on the 2-D distance)
influence = calculate_influence(w_dist, r)
# new w = old w + (learning rate * influence * delta)
# where delta = input vector (t) - old w
new_w = w + (l * influence * (t - w))
net[x, y, :] = new_w.reshape(1, 3)
I think it is supposed to be
w_dist = np.sum((np.array([x, y]) - bmu) ** 2)
The text was updated successfully, but these errors were encountered:
Hallo, I am trying to understand your syntax for som implementation form scratch. I found something is not right.
I think it is supposed to be
w_dist = np.sum((np.array([x, y]) - bmu) ** 2)
The text was updated successfully, but these errors were encountered: