Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Created August 27, 2018 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NMZivkovic/bd0a2388e2dc4df28e3a953f4c1b785b to your computer and use it in GitHub Desktop.
Save NMZivkovic/bd0a2388e2dc4df28e3a953f4c1b785b to your computer and use it in GitHub Desktop.
#Calculating BMU
input_matix = tf.stack([self._input for i in range(x*y)])
distances = tf.sqrt(tf.reduce_sum(tf.pow(tf.subtract(self._weights, input_matix), 2), 1))
bmu = tf.argmin(distances, 0)
#Get BMU location
mask = tf.pad(tf.reshape(bmu, [1]), np.array([[0, 1]]))
size = tf.cast(tf.constant(np.array([1, 2])), dtype=tf.int64)
bmu_location = tf.reshape(tf.slice(self._locations, mask, size), [2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment