75
1 © 2016 The MathWorks, Inc. Embracing Technical Computing Trends with MATLAB Accelerating the Pace of Engineering and Science Graz, 14. Oktober 2016 Michael Glaßer Dipl.-Ing. Senior Application Engineer

Embracing Technical Computing Trends with MATLABphysik.uni-graz.at/tancs2016/files/Glasser_MATLAB.pdf · Embracing Technical Computing Trends with MATLAB ... Use live scripts to teach

  • Upload
    vannhu

  • View
    220

  • Download
    4

Embed Size (px)

Citation preview

1© 2016 The MathWorks, Inc.

Embracing Technical Computing Trends with MATLABAccelerating the Pace of Engineering and Science

Graz, 14. Oktober 2016

Michael Glaßer Dipl.-Ing.

Senior Application Engineer

2

Elements of a Great Technical Computing Environment

Obvious components:

– Data analysis environment

– Programming environment

Less obvious:

– Interactive + programmatic

– Code analysis environment

– Hardware connectivity

– Automation of workflows

– Scalability and Deployment

– Collaboration

3

MATLAB – A Platform for Technical Computing

Equations

Data Surface fitting

ShareAccess Explore & Create

Derivation & solving

Optimization

Report

Application

Report

Application

ShareAccess

Reports and

Documentation

Outputs for Design

Applications

Explore & Create

Data Analysis Files

Hardware

SoftwareMathematical

Modeling

Algorithm

Development

Application

Development

x yE =V

R

Equations

F = ma

4

MATLAB – A Platform for Technical Computing

Reporting and

Documentation

Outputs for Design

Deployment

ShareExplore & Discover

Data Analysis

& Modeling

Algorithm

Development

Application

Development

Files

Software

Hardware

Access

Code & Applications

Automate

Mathematical

ModelingData Analysis Algorithm

Development

Image Processing

and Computer Vision

Computational

Finance

Control Systems

CommunicationsDigital Signal

Processing

5

Focusing on Three Types of Modeling

Parametric Modeling

– Uses a known model that maps independent variables to dependent

with a set of constant unknowns

Black-box Modeling

– Uses an automatically created model that “learns” to map

the independent variables to the dependent variable

First Principle Modeling

– Uses a model derived directly from the laws of physics without

making assumptions such as empirical or fitted parameters

6

Live Editor

Accelerate exploratory

programming and analysis

Create interactive narratives

Use live scripts to teach

7

1. Mobile Cloud Computing

2. Rise of Data Analytics and Machine Learning

3. Advanced Algorithms for Everyone

4. Mainstreaming of Low Cost Hardware

5. Increasing Quality Demands

Trends in Technical Computing

8

What are Your Challenges?…or trends you‘re interested?

…referring to today‘s theme: „Trends in algebraic and numeric computing systems“

9

1. Mobile Cloud Computing

2. Rise of Data Analytics and Machine Learning

3. Advanced Algorithms for Everyone

4. Mainstreaming of Low Cost Hardware

5. Increasing Quality Demands

Trends in Technical Computing

10

What is the Cloud?

Compute is not local

– Using applications that

are not installed on your

computer or mobile device

– Using external compute resources

to power applications installed

on your devices

Storage is not local

– Storing data outside your

computer or mobile deviceSource: https://de.wikipedia.org/wiki/Cloud_Computing

11

MATLAB Online

https://de.mathworks.com/products/matlab-online/

12

MATLAB MobileSupport for iPhone, iPad & Android

https://de.mathworks.com/products/matlab-mobile/

13

14

Faculty Creates Course

15

Faculty Defines Assignments & Problems

16

Students Invited into Course

17

Students Do Coursework

18

“After the solution I come up

with ends up in the middle of

the graph I feel disappointed.

But then I learn there's a

command that does something

I didn't know about and I feel

better about myself because I

learned a new command!” –

Rodolfo on Cody

Learning Analytics

20

Cody Coursework™ Catalog

Instructor access only

Copy pre-built problems and courses

Organize and edit

23

Cloud Computing From Your DesktopMATLAB Distributed Computing Server on Amazon EC2

24

ThingSpeak

Collect data from internet-connected

sensors and run MATLAB analytics

on the cloud using functions from:

– Statistics and Machine Learning Toolbox

– Signal Processing Toolbox

– Curve Fitting Toolbox

– Mapping Toolbox

25

Example: Deploying MATLAB Applications to the Cloud

26

1. Mobile Cloud Computing

2. Rise of Data Analytics and Machine Learning

3. Advanced Algorithms for Everyone

4. Mainstreaming of Low Cost Hardware

5. Increasing Quality Demands

Trends in Technical Computing

27

Data-Driven Decisions and Data-Driven Design

Rapid growth of measurement devices, data, and compute power

Corresponding growth of analysis

– Lots of data (and many variables)

– Lots of compute power required

– Systems are often too complex to know the governing equation

(e.g., black-box modeling)

An opportunity for better decisions and design

– Critical need for rapid decision making and rapid design iteration remains

28

Data

Analytics

DATA

• Engineering, Scientific, and Field

• Business and Transactional

Data Analytics in the Industry(Auto, Aero, Machinery, Medical Devices, etc.)

Embedded Systems

Developed with Model-Based Design

Enterprise

IT Systems

29

Why MATLAB?

Data

Analytics

DATA

• Engineering, Scientific, and Field

• Business and Transactional

MATLAB Analytics work

with business and

engineering data

MATLAB lets engineers do

Data Science

themselves

1

2

Embedded Systems

Developed with Model-Based Design

Enterprise

IT Systems

MATLAB Analytics run anywhere

3

30

Machine Learning

31

Machine Learning is Everywhere

Image Recognition

Speech Recognition

Stock Prediction

Medical Diagnosis

Data Analytics

Robotics

and more…

[TBD]

32

Machine Learning

Machine learning uses data and produces a program to perform a task

Standard Approach Machine Learning Approach

𝑚𝑜𝑑𝑒𝑙 = <𝑴𝒂𝒄𝒉𝒊𝒏𝒆𝑳𝒆𝒂𝒓𝒏𝒊𝒏𝒈𝑨𝒍𝒈𝒐𝒓𝒊𝒕𝒉𝒎

>(𝑠𝑒𝑛𝑠𝑜𝑟_𝑑𝑎𝑡𝑎, 𝑎𝑐𝑡𝑖𝑣𝑖𝑡𝑦)

Computer

Program

Machine

Learning

𝑚𝑜𝑑𝑒𝑙: Inputs → OutputsHand Written Program Formula or Equation

If X_acc > 0.5

then “SITTING”

If Y_acc < 4 and Z_acc > 5

then “STANDING”

𝑌𝑎𝑐𝑡𝑖𝑣𝑖𝑡𝑦= 𝛽1𝑋𝑎𝑐𝑐 + 𝛽2𝑌𝑎𝑐𝑐+ 𝛽3𝑍𝑎𝑐𝑐 +

Task: Human Activity Detection

33

“essentially, all models are wrong,

but some are useful”

– George Box

34

Different Types of Learning

Machine

Learning

Supervised

Learning

Classification

Regression

Unsupervised

LearningClustering

Discover an internal representation from

input data only

Develop predictivemodel based on bothinput and output data

Type of Learning Categories of Algorithms

• No output - find natural groups and

patterns from input data only

• Output is a real number

(temperature, stock prices)

• Output is a choice between classes

(True, False) (Red, Blue, Green)

35

Different Types of Learning

Machine

Learning

Supervised

Learning

Classification

Regression

Unsupervised

LearningClustering

Discover an internal representation from

input data only

Develop predictivemodel based on bothinput and output data

Type of Learning Categories of Algorithms

Linear

Regression

GLM

Decision

Trees

Ensemble

Methods

Neural

Networks

SVR,

GPR

Nearest

Neighbor

Discriminant

AnalysisNaive Bayes

Support

Vector

Machines

kMeans, kmedoids

Fuzzy C-MeansHierarchical

Neural

Networks

Gaussian

Mixture

Hidden Markov

Model

36

MODEL

PREDICTION

Machine Learning Workflow

Train: Iterate till you find the best model

Predict: Integrate trained models into applications

MODELSUPERVISED

LEARNING

CLASSIFICATION

REGRESSION

PREPROCESS

DATA

SUMMARY

STATISTICS

PCAFILTERS

CLUSTER

ANALYSIS

LOAD

DATAPREPROCESS

DATA

SUMMARY

STATISTICS

PCAFILTERS

CLUSTER

ANALYSIS

NEW

DATA

37

Example: Classification

Machine

Learning

Supervised

Learning

Classification

Regression

Unsupervised

LearningClustering

Develop predictivemodel based on bothinput and output data

Type of Learning Categories of AlgorithmsObjective:Train a classifier to classify human activity from sensor data

Data:

Approach:– Import data

– Interactively train and compare

classifiers

– Test results on new sensor data

Inputs 3-axial Accelerometer3-axial Gyroscope

Outputs

Discover an internal representation from

input data only

38

PREDICTIONMODEL

Machine Learning Workflow for Example

Train: Iterate till you find the best model

Predict: Integrate trained models into applications

MODELSUPERVISED

LEARNING

CLASSIFICATION

REGRESSION

PREPROCESS

DATA

SUMMARY

STATISTICS

PCAFILTERS

CLUSTER

ANALYSIS

LOAD

DATA

PREPROCESS

DATA

SUMMARY

STATISTICS

PCAFILTERS

CLUSTER

ANALYSIS

TEST

DATA

Classification

Learner

40

Classification Learner

App to apply advanced classification methods to your data

Added to Statistics and Machine Learning Toolbox

in R2015a

Adding in R2015b:

– Discriminant analysis

– Dimension reduction via PCA

– Parallel coordinates plot

– Categorical predictors

Also: Table and categorical support via command line

41

Example: Regression

Machine

Learning

Supervised

Learning

Classification

Regression

Unsupervised

LearningClustering

Develop predictivemodel based on bothinput and output data

Type of Learning Categories of Algorithms Objective:

Easy and accurate computation of day-ahead system load forecast

Discover an internal representation from

input data only

42

Example: Clustering

Machine

Learning

Supervised

Learning

Classification

Regression

Unsupervised

LearningClustering

Develop predictivemodel based on bothinput and output data

Type of Learning Categories of Algorithms

Objective:

Given data for engine speed and vehicle speed, identify clusters

Discover an internal representation from

input data only

44

What is Deep Learning?

Deep learning performs end-end learning by learning features,

representations and tasks directly from images, text and sound

Traditional Machine Learning

Machine

Learning

ClassificationManual Feature Extraction

Truck

Car

Bicycle

Deep Learning approach

…𝟗𝟓%𝟑%

𝟐%

Truck

Car

Bicycle

Convolutional Neural Network (CNN)

Learned featuresEnd-to-end learning

Feature learning + Classification

45

Demo : Live Object Recognition with Webcam

46

Trends in Technical Computing

1. Mobile Cloud Computing

2. Rise of Data Analytics

3. Advanced Algorithms for Everyone

4. Mainstreaming of Low Cost Hardware

5. Increasing Quality Demands

47

Making New Technologies AccessibleFrom x = A\b to Apps

New technologies, techniques, and data sources are

becoming available at a rapid rate

– e.g. GPUs, big data, cloud computing, mobile computing, apps

You’d like to take advantage of these, but…

– They’re complex

– They require new algorithms

– Do you have the time/background to invest heavily in all of them?

We make it accessible

Learn and apply (immediately)

48

High Performance ComputingMulticore and Multiprocessor Support

Threaded libraries for multicore

math operations, since R2007b.

Support for additional functions

in each release

49

Parallel Computing ParadigmMulticore Desktops

Multicore Desktop

Core 5

Core 1 Core 2

Core 6

MATLAB Desktop

(client)

Worker Worker

Worker Worker

MATLAB multicore

50

Parallel Computing ParadigmCluster Hardware

Cluster of computers

Core 5

Core 1 Core 2

Core 6

MATLAB Desktop

(client)

Core 5

Core 1 Core 2

Core 6

Core 5

Core 1 Core 2

Core 6 Core 5

Core 1 Core 2

Core 6

Worker Worker

Worker Worker

Worker Worker

Worker Worker

Worker Worker Worker Worker

Worker Worker Worker Worker

51

High Performance ComputingMulticore and Multiprocessor Support

Regular MATLAB “for” loop

for i = 1:10

long_running_code

end

“parfor” in Parallel

Computing Toolbox

parpool

parfor i = 1:10

long_running_code

end

52

Example: Parameter Sweep Parallel for-loops

Deflection of customizable truss

– Initial dynamic load, damping

– Parameters investigated:

Height of truss

Cross sectional area of truss elements

Convert for to parfor

Use pool of MATLAB workers

Scale the same algorithm to run on a cluster

𝑀 ሷ𝑥 + 𝐶 ሶ𝑥 + 𝐾𝑥 = 𝐹

53

Workers

in pool

Compute time

(minutes)

4000

values

144

values

16

values

1 241 0.90 0.11

8 32 0.12 0.03

16 16 0.07 0.02

32 8 0.04 0.02

64 4 0.03 0.02

100 3 0.02 0.02

Benchmark: Parameter Sweep of ODEsScaling case study with a compute cluster

Processor: Intel Xeon E5-class v2

16 physical cores per node

MATLAB R2014a

Workers

in pool

Compute time

(minutes)

40000

values

144

values

16

values

1 241 0.90 0.11

8 32 0.12 0.03

16 16 0.07 0.02

32 8 0.04 0.02

64 4 0.03 0.02

100 3 0.02 0.02

54

Parallel Computing ParadigmNVIDIA GPUs

Using NVIDIA GPUs

MATLAB Desktop

(client)

GPU cores

Device Memory

55

Run Same Code on CPU and GPUSolving 2D Wave Equation

0

10

20

30

40

50

60

70

80

0 512 1024 1536 2048

Tim

e (

se

co

nd

s)

Grid size

18 x

faster

23x

faster

20x

faster

GPU

NVIDIA Tesla K20c

706MHz

2496 cores

memory bandwith 208 Gb/s

CPU

Intel(R) Xeon(R)

W3550 3.06GHz

4 cores

memory bandwidth 25.6 Gb/s

56

High Performance ComputingGPU Example – Required Code Changes

57

Run Same Code on GPU or CPU: overloaded functions

58

Interactive Algorithms with MATLAB Apps

59

Finding More Apps

60

Add-On Explorer

Add capabilities to MATLAB, including community-authored and

MathWorks toolboxes, apps, functions, models, and hardware support

– Browse and install add-ons

directly from MATLAB

– Access community-authored

content from File Exchange

61

How can you make your

algorithms more accessible?

62

App DesignerIntegrates the Primary Tasks of App Building

Apps are interactive applications for

performing common tasks

App Designer makes app building more

efficient by letting you quickly move between

visual design and code development

App Designer includes:

– Enhanced design environment

– Expanded UI component set

– Code integration

63

Authoring Apps

64

Authoring Apps

Filter Design

65

Authoring Apps

66

Trends in Technical Computing

1. Mobile Cloud Computing

2. Rise of Data Analytics

3. Advanced Algorithms for Everyone

4. Mainstreaming of Low Cost Hardware

5. Increasing Quality Demands

67

Mainstreaming of Low Cost Hardware

Arduino

– 1.000,000+ have been commercially produced

– $30 (UNO), $55 (Mega 2560), $55 (Due)

Raspberry Pi

– 10,000,000th Pi shipped in 2016

– $35 (Model B)

LEGO Mindstorms EV3

– 3rd generation from LEGO Mindstorms

– $350 (for base set)

69

Low Cost HardwareTethered Approach

70

Low Cost HardwareEmbedded Approach

71

Download Hardware Support Packages

72

http://makerzone.mathworks.com/

73

Trends in Technical Computing

1. Mobile Cloud Computing

2. Rise of Data Analytics

3. Advanced Algorithms for Everyone

4. Mainstreaming of Low Cost Hardware

5. Increasing Quality Demands

74

Code Quality

Writing “better” code

– Less error-prone

– Human readable code

– Performance tuning

Robustness

– Validate, guard inputs/outputs

– Handle errors, exceptions

75

Improving Code Robustness in MATLAB

Design Decisions

Checking McCabe complexity

Input and error handling

onCleanup for clean exit

Style guidelines

76

Input and Error Handling

Check input arguments

– Validateattributes

– isscalar, isnumeric,…

– varargin, nargin

– inputParser

Handle exceptions

– try … catch

– MException

Warn or Error

– assert

– warning, error

77

Effectively Test Your Code in MATLAB

MATLAB Unit Test Framework

– Script-based interface

– Function-based interface

– Object-oriented interface

Report generation and publishing

78

Source Control Integration

Manage your code from within

the MATLAB Desktop

Leverage modern source

control capabilities

– GIT and Subversion integration

in Current Folder browser

Use Comparison Tool to

view and merge changes

between revisions

79

Collaborating using GitHub

80

1. Mobile Cloud Computing

2. Rise of Data Analytics and Machine Learning

3. Advanced Algorithms for Everyone

4. Mainstreaming of Low Cost Hardware

5. Increasing Quality Demands

Trends in Technical Computing

81© 2016 The MathWorks, Inc.