master class: deep learning for signals · 7 deep learning is a type of machine learning in which a...

75
1 © 2015 The MathWorks, Inc. Master Class: Deep Learning for Signals Abhijit Bhattacharjee Senior Application Engineer MathWorks

Upload: others

Post on 28-May-2020

22 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

1© 2015 The MathWorks, Inc.

Master Class:

Deep Learning for Signals

Abhijit Bhattacharjee

Senior Application Engineer

MathWorks

Page 2: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

2

Music Genre Classification

Page 3: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

3

Page 4: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

4

Page 5: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

5

Agenda

Why deep learning?

Deep learning with signal data

(Demo) Speech Command Recognition

(Demo) LSTM Networks

Enabling Features in MATLAB

Deploying deep learning

Page 6: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

6

What is Deep Learning?

Page 7: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

7

Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data.

Deep learning is usually implemented using a neural network architecture.

Page 8: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

8

Deep Learning

What is Deep Learning?

Machine

Learning

Deep

Learning

▪ Subset of machine learning with automatic feature extraction

– Can learn features directly from data

– More Data = better model

Page 9: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

9

Types of Datasets

Tabular

Data

Time Series/

Signal

Image

Data

ML or LSTMLSTM or CNN

CNN

Page 10: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

10

Image Example: Object recognition using deep learning

Training (GPU)

Millions of images from 1000

different categories

PredictionReal-time object recognition using

a webcam connected to a laptop

Page 11: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

11

Signals Example: Analyzing signal data using deep learning

Signal Classification using LSTMs Speech Recognition using CNNs

Page 12: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

12

Deep Learning Workflow

Files

Databases

Sensors

ACCESS AND EXPLORE

DATA

DEVELOP PREDICTIVE

MODELS

Hardware-Accelerated

Training

Hyperparameter Tuning

Network Visualization

LABEL AND PREPROCESS

DATA

Data Augmentation/

Transformation

Labeling Automation

Import Reference

Models

INTEGRATE MODELS WITH

SYSTEMS

Desktop Apps

Enterprise Scale Systems

Embedded Devices and

Hardware

Page 13: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

13

How Does a Convolutional Neural Network Work?

ObjectsShapes

Edges

Page 14: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

14

Speech Command Recognition

Using Convolutional Neural Networks

No

Up

Right

Off

Page 15: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

15

Example: Speech Command Recognition Using Deep

Learning

CNN Network for Audio Classification

Stop

Up

Yes

<none>

audioDatastore

auditorySpectrogram

auditorySpectrogram

audioDeviceReader

"Up"

1. Train

2. Predict

Google speech

command dataset

Page 16: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

16

Command

Recognition Demo

Page 17: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

17

Page 18: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

18

Page 19: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

19

Page 20: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

20

Page 21: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

21

Page 22: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

22

Page 23: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

23

Page 24: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

24

Page 25: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

25

Page 26: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

26

Page 27: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

27

https://www.isca-speech.org/archive/interspeech_2015/papers/i15_1478.pdf

Page 28: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

28

Page 29: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

29

Page 30: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

30

Page 31: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

31

Page 32: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

32

Page 33: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

33

Page 34: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

34

Page 35: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

35

Page 36: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

36

MATLAB Based Algorithm Wins the 2017 PhysioNet/CinC

Challenge to Automatically Detect Atrial Fibrillation

Challenge

Design an algorithm that uses machine learning to detect

atrial fibrillation and other abnormal heart rhythms in

noisy, single-lead ECG recordings

SolutionUse MATLAB to analyze ECG data, extract features using

signal processing and wavelet techniques, and evaluate

different machine learning algorithms to train and

implement a best-in-class classifier to detect AF

Results

▪ First place in PhysioNet/CinC Challenge achieved

▪ ECG data visualized in multiple domains

▪ Feature extraction accelerated with parallel

processing

“I don’t think MATLAB has any strong competitors for

signal processing and wavelet analysis. When you add in

its statistics and machine learning capabilities, it’s easy to

see why nonprogrammers enjoy using MATLAB,

particularly for projects that require combining all these

methods.”

- Ali Bahrami Rad, Aalto University

Link to user story

Block diagram for Black Swan’s atrial fibrillation detection

algorithm.

Page 37: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

37

Agenda

Why deep learning?

Deep learning with signal data

(Demo) Speech Command Recognition

(Demo) LSTM Networks

Enabling Features in MATLAB

Deploying deep learning

Page 38: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

38

I was born in France. I speak __________ ?

Page 39: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

39

Recurrent Neural Networks

▪ Take previous data into account when making new predictions

▪ Signals, text, time series

Page 40: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

40

I was born in France…

[2000 words]

… I speak __________ ?

Page 41: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

41

Long Short Term Memory Networks

▪ RNN that carries a memory cell throughout the process

▪ Sequence Problems

c0 C1 Ct

Page 42: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

42

LSTM

Demo

Page 43: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

43

Time Series Classification (Human Activity Recognition)

Long short-term memory networks

▪ Dataset is accelerometer and gyroscope

signals captured with a smartphone

▪ Data is a collection of time series with 9

channels

Deep

Learning

sequence to one

Page 44: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

44

Page 45: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

45

Agenda

Why deep learning?

Deep learning with signal data

(Demo) Speech Command Recognition

(Demo) LSTM Networks

Enabling Features in MATLAB

Deploying deep learning

Page 46: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

46

Deep Learning on CPU, GPU, Multi-GPU and Clusters

Single CPU

Single CPUSingle GPU

HOW TO TARGET?

Single CPU, Multiple GPUs

On-prem server with GPUs

Cloud GPUs(AWS)

Page 47: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

47

Audio Datastore

▪ Programmatic interface to large

collections of audio files

▪ (Optional) auto-generation of

labels from folder names

▪ Label-based indexing and

partitioning

▪ Random file sampling

▪ Automatic sequential file reading

▪ Parallel access for pre-

processing, feature extraction, or

data augmentation

ads =

Datastore with properties:

Files: {

' ...\Temp\speech_commands_v0.01\_background_noise_

' ...\Local\Temp\speech_commands_v0.01\_background_noise_

' ...\Local\Temp\speech_commands_v0.01\_background_noise_

... and 64724 more

}

Labels: [_background_noise_; _background_noise_; _background_noise_ ... and 64724 more categorical]

ReadMethod: 'File'

OutputDataType: 'double'

ads = audioDatastore('.\Dataset', ...

'IncludeSubfolders',true, ...

'FileExtensions','.wav', ...

'LabelSource','foldernames')

ads = getSubsetDatastore(ads,isCommand|isUnknown);

countEachLabel(ads)

ans =

11×2 table

Label Count

_______ _____

down 2359

go 2372

left 2353

no 2375

off 2357

on 2367

right 2367

stop 2380

unknown 4143

up 2375

yes 2377

[adsTrain,adsValidation,adsTest] = splitData(ads,datafolder);

Page 48: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

48

“I love to label and

preprocess my data”

~ Said no engineer, ever.

Page 49: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

49

Audio Labeler

▪ Work on collections of

recordings or record new audio

directly within the app

▪ Navigate dataset and playback

interactively

▪ Define and apply labels to

– Entire files

– Regions within files

▪ Import and export audio folders,

label definitions and datastores

Page 50: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

50

Page 51: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

51

Signal Analyzer App

• Navigate through signals

• Extract regions of interest

• Generate MATLAB scripts

Analyze multiple signals in time, frequency and time-frequency domains

Page 52: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

52

Feature Extraction: Time-Frequency Analysis

Reassigned spectrogram

and synchrosqueezing

Persistent spectrum Wavelet scalogram Constant Q transform

Empirical mode decomposition Kurtogram Instantaneous frequency

Instantaneous BWHilbert-Huang transform

Page 53: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

53

Enabling Features Summary

Train Predict

Ground

Truth

Labeling

Read &

PartitionRecord &

store

Process

&

augment

Extract

Features

(For Audio Applications) Audio System Toolbox

(For Signal Applications) Signal Processing Toolbox

Neural Network TB

Stats & ML TB

ads =

Datastore with properties:

Files: {' ...\Temp\speech_commands_v0.01\_background_noise_\doing_the_dishes.wav';' ...\Local\Temp\speech_commands_v0.01\_background_noise_\dude_miaowing.wav';' ...\Local\Temp\speech_commands_v0.01\_background_noise_\exercise_bike.wav'... and 64724 more

}Labels: [_background_noise_; _background_noise_; _background_noise_ ... and 64724 more

categorical]ReadMethod: 'File'

OutputDataType: 'double'

Pro

toty

pe!

Page 54: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

54

Agenda

Why deep learning?

Deep learning with signal data

(Demo) Speech Command Recognition

(Demo) LSTM Networks

Enabling Features in MATLAB

Deploying deep learning

Page 55: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

55

Deploying Deep Learning Models for Inference

Code

Generation

CNN

NVIDIA

TensorRT &

cuDNN

Libraries

ARM

Compute

Library

Intel

MKL-DNN

Library

Page 56: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

56

GPU Coder Fills a Gap in the Deep Learning Solution

Access Data Preprocess Select Network Train

Image Acq.Image

Processing

Computer

Vision

Neural

NetworkPCT

GPU

Coder

Deploy

InferenceTraining

Page 57: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

57

With GPU Coder, MATLAB is fast

Intel® Xeon® CPU 3.6 GHz - NVIDIA libraries: CUDA9 - cuDNN 7 - Frameworks: TensorFlow 1.8.0, MXNet 1.2.1, PyTorch 0.3.1

GPU Coder is faster

than TensorFlow,

MXNet and Pytorch

TensorFlow

MXNet

GPU Coder

PyTorch

Page 58: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

58

MathWorks can help you do Deep Learning

▪ Guided evaluations with a MathWorks deep learning engineer

▪ Proof-of-concept projects

▪ Deep learning hands-on workshop

▪ Seminars and technical deep dives

▪ Deep learning onramp course

▪ Consulting services

▪ Training courses

▪ Technical support

▪ Advanced customer support

▪ Installation, enterprise, and cloud deployment

▪ MATLAB for Deep Learning

Free resources More options

Page 59: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

59

Thank you!

Page 60: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

60

Extra Slides

Page 61: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

61

Machine learning vs. deep learning

Deep learning performs end-to-end learning by learning features, representations and tasks directly

from images, text, sound, and signals

Machine Learning

Deep Learning

Machine

Learning

Deep

Learning

Subset of machine

learning with automatic

feature extraction

Page 62: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

62

Feature Extraction: Spectral Analysis

Welch periodogram BW measurements Lomb periodogram

Octave spectrum Harmonic distortion Spectral statistics

Page 63: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

63

Features Extraction and Signal Segmentation

For Machine and Deep Learning

▪ Mel Frequency Cepstral Coefficients (MFCC)

▪ Pitch

▪ Voice Activity Detection

Page 64: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

64

Mel Frequency Cepstral Coefficients (MFCC)

▪ Variation of "perceptually-adjusted" spectrum content over time

▪ Most common voice and speech features for Machine Learning applications

▪ Option of:

– mfcc function,

– cepstralFeatureExtractor System object

– Cepstral Feature Extractor block (Simulink)

▪ Returns:

– MFCC

– "Delta" (= mfcc[n]-mfcc[n-1])

– "Delta delta" (= delta[n]-delta[n-1])

Page 65: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

65

Pitch Extraction

▪ Estimate audio pitch over time

▪ Popular feature for machine learning in

voice and speech processing

▪ Choice of 5 different popular algorithms

– 'NCF' – Normalized Correlation Function

– 'PEF' – Pitch Estimation Filter

– 'CEP' – Cepstrum Pitch Determination

– 'LHS' – Log-Harmonic Summation

– 'SRH' – Summation of Residual Harmonics

[ft, idx] = pitch(audioIn, fs);

Page 66: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

66

Voice Activity Detection (VAD)

▪ Standard algorithm to segment voice and speech signals

▪ voiceActivityDetector System object for MATLAB

▪ Voice Activity Detector block for Simulink

>> vad = voiceActivityDetector

vad =

voiceActivityDetector with properties:

InputDomain: 'Time'Window: 'Hann'

FFTLength: []SilenceToSpeechProbability: 0.2000SpeechToSilenceProbability: 0.1000

Page 67: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

67

TensorRT speeds up inference for TensorFlow and GPU Coder

Images / S

ec

TensorFlow

GPU Coder

cuDNN TensorRTIntel® Xeon® CPU 3.6 GHz - NVIDIA libraries: CUDA9 - cuDNN 7 - Frameworks: TensorFlow 1.6.0, MXNet 1.1.0, MATLAB 18a

Page 68: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

68

GPU Coder with TensorRT provides best performance across

all batch sizesIm

ages / S

ec

Batch Size

GPU Coder

GPU Coder/TensorRT

TensorFlow

TensorFlow/TensorRT

MXNet

Page 69: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

69

Embedded: GPU Coder also fastIm

ages / S

ec

NVIDIA libraries: CUDA9 - cuDNN 7 – Jetpack 3.2.1 - Frameworks: TensorFlow 1.6.0, MXNet 1.1.0, MATLAB 18a

Page 70: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

70

Example: Speech Denoising with Deep Learning

CNN & Fully Connected Networks for 2-D Regression

+

1. Train

2. Predict

Page 71: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

71

Example 3: Speech Denoising with Deep Learning

CNN & Fully Connected Networks for 2-D Regression

Page 72: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

72

Speech Denoising

Demo

Page 73: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

74

Extras

Page 74: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

75

Summary and Release Timeline

Page 75: Master Class: Deep Learning for Signals · 7 Deep learning is a type of machine learning in which a model learns to perform tasks directly from image, time-series or text data. Deep

77