We proceed with the recipe as follows:
- First, we load the necessary libraries and start a graph session, as follows:
import matplotlib.pyplot as plt import numpy as np import tensorflow as tf from sklearn import datasets sess = tf.Session()
- Now, we generate the data. The data we will generate will be two concentric rings of data; each ring will belong to a different class. We have to make sure that the classes are -1 or 1 only. Then we will split the data into x and y values for each class for plotting purposes. To do this, use the following code:
(x_vals, y_vals) = datasets.make_circles(n_samples=500, factor=.5, noise=.1) y_vals = np.array([1 if y==1 else -1 for y in y_vals]) class1_x = [x for i,x in enumerate(x_vals) ...