How to do it...

We proceed with the recipe as follows:

  1. As always, we start with importing the necessary modules:
import tensorflow as tfimport numpy as npimport matplotlib.pyplot as plt%matplotlib inline
  1. 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 ...

Get TensorFlow 1.x Deep Learning Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.