Book Image

Hands-On Neural Networks

By : Leonardo De Marchi, Laura Mitchell
Book Image

Hands-On Neural Networks

By: Leonardo De Marchi, Laura Mitchell

Overview of this book

Neural networks play a very important role in deep learning and artificial intelligence (AI), with applications in a wide variety of domains, right from medical diagnosis, to financial forecasting, and even machine diagnostics. Hands-On Neural Networks is designed to guide you through learning about neural networks in a practical way. The book will get you started by giving you a brief introduction to perceptron networks. You will then gain insights into machine learning and also understand what the future of AI could look like. Next, you will study how embeddings can be used to process textual data and the role of long short-term memory networks (LSTMs) in helping you solve common natural language processing (NLP) problems. The later chapters will demonstrate how you can implement advanced concepts including transfer learning, generative adversarial networks (GANs), autoencoders, and reinforcement learning. Finally, you can look forward to further content on the latest advancements in the field of neural networks. By the end of this book, you will have the skills you need to build, train, and optimize your own neural network model that can be used to provide predictable solutions.
Table of Contents (16 chapters)
Free Chapter
Section 1: Getting Started
Section 2: Deep Learning Applications
Section 3: Advanced Applications

Keras for expression recognition

Let's now see a more complex problem—recognize facial expressions from pictures of human faces. For this we will use the Facial Expression Recognition (FER) 2013 dataset. This is a challenging task, as there are many mislabelled images, some are not centered well, and a few are not even human faces. Currently, in the literature, accuracy is below 75% for CNNs trained from scratch on only the FER 2013 dataset.

The FER 2013 dataset is provided on a comma-separated values (CSV) file, but as we want to demonstrate another way of reading the data we will transform it into a collection of images to make it easier to inspect the dataset:

#!/usr/bin/env python
# coding: utf-8

import os
import pandas as pd
from PIL import Image

# Pixel values range from 0 to 255 (0 is normally black and 255 is white)
basedir = os.path.join('..', 'data...