- To start, we load the necessary libraries. We are also loading some PCA tools from sklearn so that we can change the resulting data from four dimensions to two dimensions for visualization purposes:
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
from sklearn import datasets
from scipy.spatial import cKDTree
from sklearn.decomposition import PCA
from sklearn.preprocessing import scale
- We start a graph session, and load the iris dataset:
sess = tf.Session()
iris = datasets.load_iris()
num_pts = len(iris.data)
num_feats = len(iris.data)
- We'll now set the groups, generations, and create the variables we need for the graph:
k=3 generations = 25 data_points = tf.Variable(iris.data) cluster_labels ...
Get TensorFlow Machine Learning Cookbook - Second Edition now with O’Reilly online learning.
O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.