#### Overview of this book

Machine learning as a field promises to bring increased intelligence to the software by helping us learn and analyse information efficiently and discover certain patterns that humans cannot. This book will be your guide as you embark on an exciting journey in machine learning using the popular Swift language. We’ll start with machine learning basics in the first part of the book to develop a lasting intuition about fundamental machine learning concepts. We explore various supervised and unsupervised statistical learning techniques and how to implement them in Swift, while the third section walks you through deep learning techniques with the help of typical real-world cases. In the last section, we will dive into some hard core topics such as model compression, GPU acceleration and provide some recommendations to avoid common mistakes during machine learning application development. By the end of the book, you'll be able to develop intelligent applications written in Swift that can learn for themselves.
Title Page
Packt Upsell
Contributors
Preface
Free Chapter
Getting Started with Machine Learning
Classification – Decision Tree Learning
K-Nearest Neighbors Classifier
K-Means Clustering
Association Rule Learning
Linear Classifier and Logistic Regression
Neural Networks
Convolutional Neural Networks
Natural Language Processing
Machine Learning Libraries
Optimizing Neural Networks for Mobile Devices
Best Practices
Index

## Building the neuron

Considering that a biological neuron has an astonishingly complex structure (see Figure 8.1), how do we approach modeling it in our programs? Actually, most of this complexity is, so to say, at the hardware level. We can abstract it out and think of the neuron as a node in a graph, which takes one or more inputs and produces some output (sometimes called activation).

Wait, but doesn't that sound like something familiar? Yes, you are right: an artificial neuron is just a mathematical function.

The most common way to model the neuron is by using the weighted sum of inputs with the non-linearity function f:

Where w is a weights vector, x is an input vector, and b is a bias term. The y is a neuron's scalar output.

Figure 8.1: A typical motor neuron of a vertebrate. Public domain diagram from Wikimedia Commons

Figure 8.2: Artificial neuron diagram

A typical artificial neuron processes input in the following three steps, as demonstrated in the preceding diagram (Figure 8.2):

1. Take...