Book Image

TensorFlow 2.0 Quick Start Guide

By : Tony Holdroyd
Book Image

TensorFlow 2.0 Quick Start Guide

By: Tony Holdroyd

Overview of this book

TensorFlow is one of the most popular machine learning frameworks in Python. With this book, you will improve your knowledge of some of the latest TensorFlow features and will be able to perform supervised and unsupervised machine learning and also train neural networks. After giving you an overview of what's new in TensorFlow 2.0 Alpha, the book moves on to setting up your machine learning environment using the TensorFlow library. You will perform popular supervised machine learning tasks using techniques such as linear regression, logistic regression, and clustering. You will get familiar with unsupervised learning for autoencoder applications. The book will also show you how to train effective neural networks using straightforward examples in a variety of different domains. By the end of the book, you will have been exposed to a large variety of machine learning and neural network TensorFlow techniques.
Table of Contents (15 chapters)
Free Chapter
1
Section 1: Introduction to TensorFlow 2.00 Alpha
5
Section 2: Supervised and Unsupervised Learning in TensorFlow 2.00 Alpha
7
Unsupervised Learning Using TensorFlow 2
8
Section 3: Neural Network Applications of TensorFlow 2.00 Alpha
13
Converting from tf1.12 to tf2

k-Nearest Neighbors (KNN)

The idea behind KNN is relatively straightforward. Given the value of a new particular data point, look at the KNN to the point, and assign a label to the point, depending on the labels of those k neighbors, where k is a parameter of the algorithm.

There is no model as such constructed in this scenario; the algorithm merely looks at all the distances between our new point and all the other data points in the dataset, and in what follows, we are going to make use of a famous dataset that consists of three types of iris flowers: iris setosa, iris virginica, and iris versicolor. For each of these labels, the features are petal length, petal width, sepal length, and sepal width. For diagrams showing this dataset, see https://en.wikipedia.org/wiki/Iris_flower_data_set#/media/File:Iris_dataset_scatterplot.svg.

There are 150 data points (each consisting of the...