We proceed with the recipe as follows:
- As always, we start with importing the necessary modules:
import tensorflow as tfimport numpy as npimport matplotlib.pyplot as plt%matplotlib inline
- Next, we declare a class, WTU, which will perform all the tasks. The class is instantiated with m x n the size of the 2D SOM lattice, dim the number of dimensions in the input data, and the total number of iterations:
def __init__(self, m, n, dim, num_iterations, eta = 0.5, sigma = None): """ m x n : The dimension of 2D lattice in which neurons are arranged dim : Dimension of input training data num_iterations: Total number of training iterations eta : Learning rate sigma: The radius of neighbourhood function. """ self._m = m self._n ...