#### 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

## Convolution operation

Convolution is one of the most important operations in the image processing. Blurring, sharpening, edge detection, denoising, embossing and many other familiar operations in image editors are actually convolutions. It is similar to the pooling operation in some way, because it is also a sliding window operation, but instead of taking the average over the window, it performs element-wise multiplication by the kernel – matrix of size n × n and sums the result. The result of the operation depends on the kernel (also known as convolution filter) – a matrix, which is usually square, but not necessarily, see Figure 9.3. The notions of the stride and padding are the same as in the pooling case:

Figure 9.3: Different convolution filters have different effects on the picture

Convolution operation works in the following way (see the following diagram):

• The convolution kernel (filter) slides over the image from left to right, and from top to bottom
• At each position, we calculate an...