QM CIS Summer School 2018 – Tutorial
Deep learning and IoT Tutorial: an introduction to using Keras for Deep Learning car driver behavior
Stefan Poslad1,2, Zixiang Ma1,2, Rana Massoud1,2,3, Bang Wu1,2, Patricia Charlton2,4
1Center for Intelligent Sensing ,CIS, QMUL, http://cis.eecs.qmul.ac.uk/
2IoT2US Lab, QMUL, https://iot.eecs.qmul.ac.uk/
3ELIOS Lab, University of Genoa, https://elios.diten.unige.it/
4Creative Digital Solutions, contact Patricia.Charlton@pobox.com
1 Introduction and Overview
Machine Learning is one important type of Artificial Intelligence Machine Learning (ML) in which a machine or computer learns to perform tasks by considering examples, generally without being programmed with any task-specific rules.
In this tutorial we’ll have a quick look at Artificial Neural Networks (ANN’s) as 1 of the most well known ways for Machine Learning (ML). An ANN does not need to be programmed with task or application rules as it learns itself. We’ll apply a simple type of Deep Neural Network (DNN) as a subtype of ANN to two examples or applications, simple regression and a driving behavior example.
Notes: A simple definition of an DNN is it’s just a ANN with multiple hidden layers that can be used for deep learning. The 1st one was proposed in a proposed by Ivakhnenko and Lapa in 1965 so we can see the idea has been around quite a long time. There are also other ways to model deep learning.
1.1 Overview of Deep Learning
As a subtype of Machine Learning, Deep Learning (DL) is often referred to as Hierarchical Learning, in which the world is represented as nested hierarchy of concepts, with each concept defined in relation to simpler concepts, and more abstract representations derived from less abstract ones. There are two well-known applications of this for text analysis and for image processing. It can define low-level feature such as letters first then little higher-level features such as words and then higher-level features such as sentences. With respect to image recognition it means identifying light or dark areas before deriving lines and then shapes to enable face recognition.
Relative to other machine learning techniques, deep learning has four key advantages:
- Its ability to work with unlabelled data – unsupervised learning
- Its ability to learn low-level features from minimally processed raw data. It also creates nonlinear interactions automatically and can approximate any arbitrary function with enough neurons, and hidden layers, especially when deep neural networks are used.
- Its ability to detect complex interactions among features as variables that may be not be obvious, i.e., interactions that are the effect of two or more variables acting in combination rather than considering just each one individually.
- Its ability to work with high-cardinality data (values that are very uncommon or unique, e.g., identification numbers, email addresses, or user names.)
These four benefits mean that DL can produce useful results where other ML methods may fail; it can build more accurate models than other methods; and it can reduce the time needed to build a useful model. There are of course, disadvantages too:
- a DL algorithm can take a long time to train due to large number of parameters in a large data set, whereas a traditional ML algorithms in contrast can take few seconds to a few hours to train. There are however hardware accelerators to make the DL algorithm run faster, e.g., GPU (However its’ quick to test on large data sets if you compare it with k-nearest neighbors type ML algorithm) whose test time increases with the size of data.
- Compared to some other ML methods, it can be very difficult model to interpret especially if such models may have many layers and thousands of nodes; interpreting each of these individually is impossible. Data scientists instead tend to treat the DNN architecture itself as a black box and not interpret the model but more evaluate how well they the outcome is derived (predicted)
- DL also shares other machine learning methods’ propensity to overlearn or overfit the training data, i.e., the algorithm “memorizes” characteristics of the training data that may or may not generalize to the production environment where the model will be used or tested. There are to ways to avoid this, e.g., through independent validation.
1.2 Tutorial Overview
- Following this introduction (Section 1) …
- We next (Section 2 )describe two problem models, the 1st a simple regression model, how do we best estimate a dependent variable (output) giving samples of a time-series of an independent variable (single input) using a ANN, 2nd how do we create an ANN to represent fuel consumption as the dependent variable based upon several inputs that affect it this is a model of driving behaviour.
- Next we give some background to ANNs (Section 3).
- Then, we start the practical or hands-on part, 1st by setting up the ANN programming environment in Python and then we show how to program a simple regression example using this. (Section 4).
- Then we show how to program a more complex real problem, how to use a ANN to model driving behaviour (Section 5).
- Finally, we review and discussed what we covered so far and propose some further work (Section 6).
1.3 Tutorial Schedule and Organisation
There are 2 parts to this tutorial that are oriented to the two problems as follows.
Day 1 (3 hours): Hands-on ANN Tutorial – Sinusoidal Regression Example
Day 2 (3 hours): Hands-on ANN Tutorial – Driving behavior Example
Note: It’s best if this tutorial is done as a group assignment where peers 1st try to help each other with problems (unsupervised learning), rather than relay on the instructors for help (supervised learning) as the 1st port of call for help.
Note: Although it may be clearer and cleaner to separate all the ANN Theory and Background into a separate section, this would make the introduction to the hands-on session too long, an overview of NN is given at the start and then further aspects of NN are expanded upon as needed to further explain the hands-on part (the NN programmed in Python).
1.4 Learning Outcomes
During this tutorial. You will:
- Have a quick look at ANN’s in general.
- Gain an overview to understand what Deep Learning is, and how it works.
- Learn how to implement a deep learning model by the Python coding part.
- Model a deep learning fuel consumption estimator using historical naturalistic driving data
1.5 Scope and Limitations
This is not a complete course on deep learning. Instead, this tutorial is meant to get you from zero to your first Deep Neural Network with as little headache as possible! Because of the time-constraints, in this tutorial, we don’t have time to:
- Give a deep tutorial about ANN or to cover the different types of ANN, DNN, why they are different and where and when they can be used.
- We will only program a relatively simple DNN for driving behavior that has multiple hidden layers that is not as complex as a CNN or DNN
- We only tested the software on 1 OS (Win 10)) although it can be used on other OSs such as MacOS and Linux we did no test these.
- You need to have your own laptop to install or with the specified preinstalled software and enough power to last three hours for the whole tutorial as the room will not enough power points
- You need to be familiar with Python or quickly learn to use it in order to program the ANN application
1.6 Experiment Material and Reference
To obtain the full tutorial, please feel free to liaise with Zixiang and Bang.
If you’re interested in mastering the theory behind deep learning, we recommend this great course from Stanford:
For further study (more advanced Convolutional neural network and Recurrent neural network):