Anda di halaman 1dari 56

Deep Learning vs.

Machine Learning:
Choosing the Best Approach
Deep Learning vs. Machine Learning: Choosing the Right Approach

Introduction 3

Terminology 4

Your Project 7

Your Data 26

Your Hardware 35

Conclusion 52

Guess the Algorithm: Answers 56


Introduction

The internet is full of articles on the importance of AI, deep learning,


and machine learning. As an engineer or researcher, you need to
take advantage of this new and growing technology, but where do you
start? 

In this ebook, we discuss some of the key differences between deep


learning and traditional machine learning approaches to help you
decide where you should focus your initial effort. We look at three
factors that contribute to whether you should start with machine
learning or deep learning (your project, data, and hardware) and then
step through a case study that illustrates when you might want to use
them together.

This ebook assumes a basic knowledge of AI technology and


discusses the considerations that go into choosing which algorithms
you should try first. For an introduction to applying these techniques,
see Machine Learning with MATLAB and Introducing Deep Learning
with MATLAB.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 3


Terminology
Terminology

AI: Artificial intelligence (AI) is a computer system trained to perceive you manually select the relevant features to use and then train the
its environment, make decisions, and take action. model. When we refer to machine learning we exclude deep learning.
Common techniques include decision trees, regression, support vector
Machine learning: The techniques involved with building models that machines, and ensemble methods.
automatically learn from data. In this ebook, we use machine learning
as shorthand for “traditional machine learning”—the workflow in which

ARTIFICIAL MACHINE
INTELLIGENCE LEARNING DEEP LEARNING
Statistical methods that Neural networks with many layers
Any technique that
enable machines to “learn” that learn representations and tasks
enables machines to
tasks from data without “directly” from data
mimic human
intelligence explicitly programming

Deep learning more accurate


than humans on image
classification

1950s 1980s 2015


FLOPS

Thousand Million Quadrillion

The progression of data analytics algorithms.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 5


Terminology

Deep learning: A subset of machine learning modeled loosely on the


neural pathways of the human brain. A key difference from machine
learning is that instead of manually selecting the relevant features,
the algorithm automatically learns what features are useful. Common
techniques include convolutional neural networks, recurrent neural
networks, and deep Q networks.

Algorithm: The set of rules or instructions that will train the model to
do what you want it to do.

Model: The trained program that predicts outputs given a set of inputs.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 6


Your Project
Your Project: What Are You Trying to Do?

It’s helpful to start off with a clear picture of what you’re trying to
accomplish. There are few hard and fast rules when it comes to
selecting deep learning rather than machine learning algorithms, so
consider choices as if they were on a spectrum.

While one task alone might be more suited to machine learning, your
full application might involve multiple steps that are better suited to
deep learning when taken together.

This following list includes commonly performed tasks but is not


exhaustive.

Introduction to Deep Learning:


Machine Learning vs. Deep Learning (3:48)

Deep Learning vs. Machine Learning: Choosing the Best Approach | 8


Your Project: What Are You Trying to Do?

PREDICT an output based on historical and


current data.
Example: Use real-time sensor data from a motor to predict remaining
useful life for rotating machinery. The Similarity-Based Remaining
Useful Life Estimation example uses linear regression.

Applications: Predictive maintenance, financial trading, recommender


systems

Input: Sensor data, timestamped financial data, numeric data

Common algorithms: Linear regression, decision trees, support


vector machines (SVMs), neural networks, association rules

Estimating remaining useful life.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 9


Your Project: What Are You Trying to Do?

IDENTIFY objects or actions in image, video,


and signal data.
Example: Create a computer vision application that can detect
vehicles. The Object Detection Using Faster R-CNN Deep Learning
example uses a convolutional neural network.

Applications: Advanced driver assistance (ADAS) with object


detection, robotics, computer vision perception for image recognition,
activity detection, voice biometrics (voiceprint)

Input: Images, videos, signals

Common algorithms: CNNs, clustering, Viola-Jones

Using an R-CNN to detect vehicles.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 10


Your Project: What Are You Trying to Do?

MOVE physically or in a simulation.


Example: Perform robotic path planning to learn the best possible
route to a destination. The Reinforcement Learning (Q-Learning) File
Exchange submission uses a deep Q network.

Applications: Control systems, robotics in manufacturing, self-driving


cars, drones, video games

Input: Trigonometry, physics, sensor data, videos, lidar data

Common algorithms: Reinforcement learning (deep Q networks),


artificial neural networks (ANNs), CNNs, recurrent neural networks
(RNNs)

Path planning for parking.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 11


Your Project: What Are You Trying to Do?

UNCOVER trends, sentiments, fraud, or threats.


Example: Determine how many topics are present in text data. The
Analyze Text Data Using Topics Models example uses the latent
Dirichlet allocation (LDA) topic model.

Applications: Natural language processing for safety records, market


or medical research, sentiment analysis, cybersecurity, document
summarization

Input: Streaming text data, static text data

Common algorithms: RNNs, linear regression, SVMs, naïve Bayes,


latent Dirichlet allocation, latent semantic analysis, word2vec

Visualizing common words associated with a topic.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 12


Your Project: What Are You Trying to Do?

ENHANCE images and signals.


Example: Create high-resolution images from low-resolution images. Applications: Improve image resolution, denoise signals in audio
The Single Image Super-Resolution Using Deep Learning example
uses a very-deep super-resolution (VDSR) neural network. Input: Images and signal data

Common algorithms: LSTM, CNNs, VDSR neural network

Creating high-resolution images from low-resolution images.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 13


Your Project: What Are You Trying to Do?

RESPOND to speech or text commands based


on context and learned routines.
Example: Automatically recognize spoken commands like “on,” “off,”
“stop,” and “go.” The Speech Command Recognition Using
Deep Learning example uses a CNN.

Applications: Customer care calls, smart devices, virtual assistants,


machine translation and dictation

Input: Acoustic data, text data

Common algorithms: RNNs (LSTM algorithms in particular), CNNs,


word2vec

Audio signal for the spoken command "on."

Deep Learning vs. Machine Learning: Choosing the Best Approach | 14


Your Project: How Accurate Do You Need to Be?

Accuracy is a key metric in all machine learning and deep learning


projects. Early in a project, it is common to focus solely on maximizing
accuracy, with other considerations (such as model memory footprint
or prediction speed) left to be addressed later on.

Intuitively, this approach makes sense; it’s useful to have an idea of


what the maximum possible achievable accuracy is before worrying
about constraints that may reduce this accuracy in production.

You'll need more data to teach the network to distinguish between similar images,
like the African and European swallow.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 15


Your Project: How Accurate Do You Need to Be?

In general, deep learning techniques are capable of producing more


accurate results than traditional machine learning techniques, because
So, how much data is a “large” dataset? It depends. Some
they use more complex models with more parameters, so they can be
popular image classification networks available for transfer
more closely “fit” to the data.
learning were trained on a dataset consisting of 1.2 million
images from 1000 different categories.
If you have a large amount of data and an application where deep
learning is well-suited to the problem, you may want to start with deep
learning techniques because they can provide more accurate results.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 16


Your Project: How Accurate Do You Need to Be?

When focusing on accuracy, you risk overfitting your model. This


happens when your algorithm is too closely associated to your training
data, and then cannot generalize to a wider dataset.

To avoid overfitting from the start, make sure you have plenty of
training, validation, and test data. Use the training and validation data
first to train the model; the data needs to be representative of your
real-world data and you need to have enough of it. Once your model
is trained, use completely new test data to check that your model is
performing well.

An overfit model will not handle unexpected data well.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 17


Your Project: How Accurate Do You Need to Be?

If you think your model is starting to overfit the data, take a look at:

Regularization – Penalizes large parameters to help keep the model


from relying too heavily on individual data points.

Dropout probability – Randomly skips some data to avoid the model


memorizing the dataset.

Like a lot in life, there are elements of common sense and trial and
error. Most practitioners develop an intuition of how various parameters
affect accuracy through experimentation.

Just Remember…
At some point you may get close to the point of diminishing
returns, at which tweaks to the model result in insignificant
improvements in accuracy. It’s good to keep in mind the final
goal, and if possible, the business impact of incremental
Trace plot of coefficients fit by lasso.
improvements in accuracy and danger of overfitting.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 18


Your Project: Do You Need to Explain the Results?

Data scientists often refer to the ability to share and explain results as
model interpretability. A model that is easily interpretable has:
• A small number of features that typically are created from some Guess the Algorithm
physical understanding of the system
A researcher designed a way to take ultra-low-dose CT scans
• A transparent decision-making process
(which reduce the amount of radiation exposure, but also reduce
image resolution) and apply image processing techniques to
Interpretability is important for many applications that need to:
regain image resolution.
• Prove that your model complies with government
or industry standards
What technique did he use?
• Explain factors that contributed to a diagnosis
• Show the absence of bias in decision-making SVM or CNN

Deep Learning vs. Machine Learning: Choosing the Best Approach | 19


Your Project: Do You Need to Explain the Results?

If you must have the ability to demonstrate the steps the algorithm
Local interpretable model-agnostic explanations (LIME) take
took to reach a conclusion, focus your attention on machine learning
a series of individual inputs and outputs to approximate the
techniques. Decision trees are famously easy to follow down their
decision making. Read the paper.
Boolean paths of “if x, then y.”

Traditional statistics techniques such as linear and logistic regression Another area of research is the use of decision trees as a
are well accepted. Even random forests are relatively simple to explain method to illustrate a more complex model. Read the paper.
if taken one tree at a time.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 20


Your Project: Domain Knowledge

How much do you know about the system where your project sits?

If you are working on a controls application, do you understand the


related systems that might affect your project, or is your experience
more siloed?

Domain knowledge can play a part in choosing what data to include in


a model and determining the most important features of that data.

Schematic showing how the components of the elevator system are connected to one another.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 21


Your Project: Domain Knowledge

What Data Should You Include?


For example, a medical researcher wants to make sense of a large
amount of patient data. There could be thousands of features from
patient stats, from the characteristics of a disease to DNA traits to
environmental elements.

If you have a solid understanding of the data, select the features you
think will be the most influential and start with a machine learning
algorithm. If you have high-dimensional data, try dimensionality
reduction techniques such as principal component analysis (PCA) to
create a smaller number of features to try to improve results.

Features of the human mitochondrial genome.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 22


Your Project: Domain Knowledge

Feature Selection
Ensure your model is focused on the data with the most predictive
power and is not distracted by data that will not impact decision
making. Precise feature selection will result in a faster, more efficient,
more interpretable model.

If you are using a supervised machine learning algorithm, you will


need to use your domain knowledge to manually select the important
features of your data.

If you have limited domain knowledge, or your data has a wide


range of features, try automatic feature selection techniques such as
neighborhood component analysis.
Applied Machine Learning, Part 1:
Feature Engineering (4:35)

Deep Learning vs. Machine Learning: Choosing the Best Approach | 23


Your Project: Domain Knowledge

One benefit of many deep learning algorithms is that they perform A common example of using deep learning and machine learning
feature extraction and selection tasks automatically. You will still want together is to use a CNN to select features that are then fed into a
to preprocess the data, but then the model will decide for itself which machine learning algorithm. We walk through an example of how this
features of the data are the most important. can be done in Section 4.

Performing feature extraction and selection using a CNN.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 24


Your Project: Domain Knowledge

Signal processing engineers are often required to transform their


1D signals to reduce dimensionality. Signals often come in at high
frequency rates, making the amount of data untenable to process in its
raw form.

One common way is to convert 1D signals into a 2D representation


using a transform such as spectrogram.

This conversion highlights the most prominent frequencies of a signal.


This creates an “image” that can then be used as input into a CNN.

Original signal (top) and corresponding spectrograms (bottom) for words.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 25


Your Data
Your Data: Type

Tabular Data
What do we mean by tabular? Think of a database or employee Traditional machine learning techniques were designed with tabular
information where the columns are independent of each other. data in mind, so you may want to start with machine learning if your
data is tabular. There are ways to transform tabular data to work with
Tabular data can be numeric or categorical (though eventually the deep learning models, but this may not be the best option when
categorical data would be converted to numeric). starting out.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 27


Your Data: Type

Images and Video


Deep learning approaches have become the norm for many image and
video classification problems. More specifically, convolutional neural
networks are designed to extract features from images that often result
in state-of-the-art classification accuracies.

Intuitively, the operations performed by the convolutional filters are


able to extract progressively higher-level features from images, making
it possible to discern high-level differences such as cat vs. dog.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 28


Your Data: Type

Sensor and Signal


Traditional approaches involve extracting features from signals (in both
the time and frequency domains) and then using these features with a
machine learning algorithm.

More recently, signals have been passed directly to LSTM networks,


or converted to images and then used with a convolutional neural
network.

Wavelets provide yet another way to extract features from signals, with
techniques like wavelet scattering showing promising results when
combined with machine learning algorithms.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 29


Your Data: Type

Text
Traditional approaches involve converting text to a numerical
representation via bag-of-words models and normalization techniques
such as TF-IDF.

This numerical data can then be used with traditional machine learning
techniques such as support vector machines or naïve Bayes. Newer
techniques use text with recurrent or convolutional neural network
architectures.

In these cases, text is often transformed into a numeric representation


using a word-embedding model such as word2vec.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 30


Your Data: Labeling Data

To train a supervised model, whether for machine learning or deep


learning, you need labeled data.
Guess the Algorithm
If your data is not labeled, there are techniques that will help.
A consumer electronics company created a model to decide
For machine learning, unsupervised learning techniques like clustering whether a loudspeaker was good enough for a professional
can be used to segment the data into groups. These groups can then musician. With 60 speakers and more than 50 features,
be analyzed to understand what makes data points within them similar, which algorithm worked best?
and then labeled appropriately.
SVM or Artificial Neural Network

Deep Learning vs. Machine Learning: Choosing the Best Approach | 31


Your Data: Labeling Data

Retroactively labeling a large amount of data required can be


prohibitively time-consuming.

Labeling for deep learning can mean annotating objects in an image,


or each pixel of an image or video, for semantic segmentation.

Recently, graphical tools dedicated to labeling image and signal data


have become available.

Some of these tools offer sophisticated capabilities that attempt


to reduce the amount of manual labeling required, such as
recommending labels for a video frame based on labels and objects in
the previous frame.

The Ground Truth Labeler app in MATLAB.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 32


Your Data: Labeling Data

If you want to use deep learning but do not have a lot of labeled
data, consider transfer learning using a pretrained network such as
GoogLeNet, ResNet-101, or VGG-16.

Because transfer learning focuses on training a smaller number of


parameters in the deep neural network, it requires a smaller amount of
labeled data.

MATLAB® has domain-specific apps to automate labeling, including


Image Labeler, Ground Truth Labeler, and Audio Labeler. These apps
are helpful to add newly labeled data for transfer learning.

Training Deep Learning Models


with Transfer Learning (4:19)

Deep Learning vs. Machine Learning: Choosing the Best Approach | 33


Your Data: Labeling Data

Another approach for dealing with small amounts of labeled data is to


augment that data. For example, it is common with image datasets to
Just Remember…
augment the training data with various transformations on the labeled
images (such as reflection, rotation, scaling, and translation).
Image Labeler in MATLAB helps you to label
ground-truth data in a collection of images.
Although augmenting data can provide more samples, it is important to
Define rectangular region of interest (ROI)
remember that biases can still occur due to a lack of a comprehensive
labels, pixel ROI labels, and scene labels.
representation of the samples. An algorithm must be given a good
representation of the data in order to make accurate predictions.

Ground Truth Labeler works in the same way


as the Image Labeler app but is specifically for
automated driving applications.

Audio Labeler enables you to label ground-truth


audio data at both the region level and file level.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 34


Your Hardware
Your Hardware

It’s useful to think about hardware in two groups: Guess the Algorithm
• Hardware you have available to train the model. An oil company created a more efficient way to keep track of
• Hardware the model will run on in production. geo-tagged machine inventory for maintenance scheduling.
They set up a machine vision system to identify tags with serial
numbers, use object character recognition to extract numbers,
and associate images with inventory.

Which algorithm did they use?

Clustering or
Regional Convolutional Neural Network (R-CNN)

Deep Learning vs. Machine Learning: Choosing the Best Approach | 36


Your Hardware: Training the Model

Models are typically trained on a desktop machine or on a cluster or


cloud. GPUs are the norm for training most deep learning models
because they offer dramatic speed improvements over training on a
CPU. Additionally, the cluster or cloud option has gained popularity due
to the high costs associated with obtaining the GPUs, since this option
lets the hardware be shared by several researchers.

Because deep learning models take a long time to train (often on the
order of hours or days), it is common to have several models training in
parallel, with the hope that one (or some) of them will provide improved
results.

Run applications on a multicore desktop with local workers, take advantage of GPUs,
and scale up to a cluster with Parallel Computing Toolbox.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 37


Your Hardware: Training the Model

Desktop CPUs are still sufficient for training most machine learning
models.

For training models on large amounts of data, you can use big data
frameworks such as Apache Spark™ to spread the computation across
a cluster of CPUs.

Use MATLAB with data in HDFS and on Spark.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 38


Your Hardware: Running the Model in Production

Several factors will drive the architecture of the production system:


Just Remember…
• How fast does the system need results?
For embedded system designers, it’s important to consider not only
• Will a network connection always be available? algorithm performance, but also the overall system robustness,
• What hardware is available at the edge node? reliability, and cost of the architecture and design.
• How often will the model need to be updated?

Communication Connectivity

Deploy analytics
to aggregator
DATA AGGREGATOR 3
• Online analytics
• Visualization and reporting

Deploy algorithm to device

2
EDGE NODES
• Local embedded algorithms
• Data reduction EXPLORATORY ANALYSIS
1 • Historical analytics
• Algorithm development

Deep Learning vs. Machine Learning: Choosing the Best Approach | 39


Your Hardware: Running the Model in Production

The trend toward smarter and more connected sensors is adding Guess the Algorithm
pressure to move more processing and analytics as close to the
sensors as possible. This approach has the benefit of shrinking the Orbiting satellites and spacecraft in low Earth orbit are subject
amount of data that is transferred over the network, which reduces to the collision dangers of more than 500,000 pieces of space
the cost of transmission and can reduce the power consumption of debris; tracking this debris allows the spacecraft to maneuver
wireless devices. away from collision zones. Current tracking tactics are
vulnerable to orbital variations of space debris clouds due
Models that run on hardware at the edge will provide quick results to constantly changing astrodynamics subject to
without a network connection. However, enough hardware will need nonlinear celestial disturbances.
to be available at the edge to run the machine learning model, and it
will be more difficult to push out updates to the model than if the model What kind of algorithm did they use to improve safety?
resided on a centralized server.
Deep Q Network or Artificial Neural Network

Deep Learning vs. Machine Learning: Choosing the Best Approach | 40


Your Hardware: Running the Model in Production

Tools are available that can convert machine learning models, which
are typically developed in high-level interpreted languages, into
standalone C/C++ code, which can be run on low-power embedded
devices.

For deep learning models, specialized hardware is typically required


due to the higher memory and compute requirements. GPU Coder™
enables code generation that leverages optimized libraries from Intel®
(MKL-DNN), NVIDIA® (TensorRT, cuDNN), and Arm® (Arm Compute
Library) to create deployable models with high-performance inference
speed.

Pedestrian Detection on a NVIDIA GPU


with TensorRT (1:35)

Deep Learning vs. Machine Learning: Choosing the Best Approach | 41


Your Hardware: Running the Model in Production

With GPU Coder Support Package for NVIDIA GPUs, you can cross-
compile and deploy the generated CUDA code as a standalone
application on an embedded GPU such as the NVIDIA Drive platform
or the NVIDIA Jetson® board.

Just Remember…
Depending on your application, the level of validation required
before using the model in production will vary greatly. For example,
a model used in marketing to recommend ads will require
significantly less validation than a model used in a safety-critical
application. In such applications, models can be integrated with
existing validation processes such as hardware-in-the-loop (HIL) to
ensure the model runs as expected in the production environment.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 42


Your Hardware: Speed

How quickly do you need results? Speed is affected by your hardware,


the complexity and size of your data, and the algorithm you want to
use.

If you need results quickly, try machine learning algorithms first.


They are generally quicker to train and require less computational
power. The main factor in training time will be the number of variables
and observations in the training data. Whereas simple models for small
datasets can be trained almost instantly, complex models for large
datasets may still take on the order of days to train.

Use the Classification Learner app to try different classifiers on your dataset quickly.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 43


Your Hardware: Speed

Deep learning models will take time to train. The abundance of


pretrained networks and public datasets has shortened the time to
train deep learning models through transfer learning, but it is easy to
underestimate the real-world practicalities of incorporating your training
data into these networks. You may need to tweak layers, classes, and
labels.

Modern deep learning algorithms can take anywhere from a minute


to a few weeks to train, and that timing is highly dependent on your
hardware and computing power. It is common for practitioners to have
multiple deep learning models training simultaneously (which requires
additional hardware). 

The Deep Network Designer app lets you build, visualize, and edit deep learning networks.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 44


Example

Feature Extraction Using AlexNet and CIFAR-10 Dataset


Some applications use a combination of deep learning and machine
learning. This MATLAB example walks through how to extract features
from images using a pretrained convolutional neural network, and then
use these features to train a support vector machine.

The images used in this example are from the CIFAR-10 dataset.

» Follow this demo in MATLAB

Using Feature Extraction with Neural Networks


in MATLAB (3:54)

Deep Learning vs. Machine Learning: Choosing the Best Approach | 45


Example

Step 1. Bring in Alexnet


BRING IN
If this is your first time running this code, the code may cause an error ALEXNET
message that contains a link to download AlexNet. You’ll only need to
download AlexNet once.

convnet = alexnet;
ACCESS
LAYERS

TRAIN THE
NETWORK

TEST THE
NETWORK

Deep Learning vs. Machine Learning: Choosing the Best Approach | 46


Example

Step 2. Access Layers


BRING IN
convnet.Layers % Take a look at the layers ALEXNET
ans =
25x1 Layer array with layers:
 
1 'data' Image Input
227x227x3 images with 'zerocenter' ACCESS
normalization LAYERS

2 'conv1' Convolution
96 11x11x3 convolutions with
stride [4 4] and padding [0 0 0 0]
TRAIN THE
NETWORK

25 'output' Classification Output


crossentropyex with 'tench',
'goldfish', and 998 other classes TEST THE
NETWORK

Deep Learning vs. Machine Learning: Choosing the Best Approach | 47


Example

Step 3. Train
Set Up Training Data BRING IN
ALEXNET
If you are using CIFAR-10, you have the choice of 10 categories of
objects. The categories in this example were randomly chosen; you
can choose whichever categories work best for you.

rootFolder = 'cifar10Train'; ACCESS


categories = {'Deer','Dog','Frog','Cat'}; LAYERS
imds = imageDatastore(fullfile(rootFolder,
categories), 'LabelSource', 'foldernames');
imds.ReadFcn = @readFunctionTrain;
[trainingSet, ~] = splitEachLabel(imds, 50,
TRAIN THE
'randomize'); NETWORK

Things to try:
Change the number 50 to as many training images as you would
like to use. TEST THE
NETWORK
See how increasing the number of images changes the accuracy of
the classifier.

Deep Learning vs. Machine Learning: Choosing the Best Approach | 48


Example

Step 3. Train
Extract Features from the Training Set Images BRING IN
ALEXNET
Features are extracted through activations, which will pull the features
learned from the CNN up to that point in the architecture. If you use a
network trained on millions of images, such as AlexNet, you can expect
that the features pulled from the network will be very rich, complex
features that describe the objects. ACCESS
LAYERS
featureLayer = 'fc7';
trainingFeatures = activations(convnet,
trainingSet, featureLayer);
TRAIN THE
NETWORK

TEST THE
NETWORK

Deep Learning vs. Machine Learning: Choosing the Best Approach | 49


Example

Step 3. Train
Train the SVM Classifier BRING IN
ALEXNET
fitcecoc is just one of the many classifiers available. It fits a
multiclass SVM using error-correcting output codes. What about other
fitting functions like fitcknn or fitcnb?

Try the Classification Learner App for a comprehensive approach to ACCESS


finding the best classifier. LAYERS

classifier = fitcecoc(trainingFeatures,
trainingSet.Labels);
TRAIN THE
NETWORK

TEST THE
NETWORK

Deep Learning vs. Machine Learning: Choosing the Best Approach | 50


Example

Step 4. Test
Set Up Test Data BRING IN
rootFolder = 'cifar10Test'; ALEXNET
testSet = imageDatastore(fullfile(rootFolder,
categories), 'LabelSource', 'foldernames');
testSet.ReadFcn = @readFunctionTrain;
 
Extract Features from the Test Set Images, ACCESS
and Test the SVM Classifer LAYERS
testFeatures = activations(convnet, testSet,
featureLayer);
predictedLabels = predict(classifier, testFeatures);
 
TRAIN THE
Determine Overall Accuracy NETWORK
confMat = confusionmat(testSet.Labels,
predictedLabels);
confMat = confMat./sum(confMat,2);
mean(diag(confMat))
TEST THE
NETWORK

Deep Learning vs. Machine Learning: Choosing the Best Approach | 51


Conclusion
Conclusion

As we’ve seen, there are very few hard and fast rules when it comes to
choosing the best algorithm for your project. Guess the Algorithm
Most algorithms are chosen through a process of trial and error to see A research and development organization restored arm and
what works best in any given situation. hand control to a quadriplegic man by processing signals from
an electrode array implanted in his brain.
Whether you end up with a traditional machine learning algorithm or
a deep learning algorithm, MATLAB provides tools and support to get What algorithm did they use?
started with these techniques quickly.
SVM or RNN

Deep Learning vs. Machine Learning: Choosing the Best Approach | 53


Conclusion

Machine Learning

Using MATLAB, engineers and other domain experts have deployed


thousands of applications for predictive maintenance, sensor analytics,
finance, and communication electronics. MATLAB makes the hard
parts of machine learning easy with:

• Point-and-click apps for training and comparing models


• Automatic hyperparameter tuning and feature selection to optimize
model performance
• All the popular classification, regression, and clustering algorithms
for supervised and unsupervised learning
• Faster execution than open source on most statistical and machine
learning computations
Try the Classification Learner App in your browser now

Deep Learning vs. Machine Learning: Choosing the Best Approach | 54


Conclusion

Deep Learning

With just a few lines of MATLAB code, you can build deep learning
models without having to be an expert. Explore how MATLAB can help
you perform these deep learning tasks:

• Easily access the latest pretrained models


• Use apps to automate ground-truth labeling
• Accelerate algorithms on NVIDIA GPUs, cloud, and datacenter
resources
• Create, modify, and analyze complex deep neural network
architectures
• Work with models from Caffe and TensorFlow-Keras
• Collaborate with peers using frameworks like PyTorch and Apache Try deep learning in your browser now
MxNet™, using support for ONNX™ model importer and exporters

Deep Learning vs. Machine Learning: Choosing the Best Approach | 55


Guess the Algorithm: Answers

Question Answer More information

What did a researcher use to reduce radiation in CT scans? Convolutional Neural Network » Read the article

What did a consumer electronics company use to judge


Support Vector Machine » Read the article
new speakers?

What did the oil company use to identify inventory


Regional Convolution Neural Network » Watch the presentation
in images?

How did a researcher predict the path of space junk? Artificial Neural Network » Watch the presentation

What did the R&D organization use to restore limb control? Support Vector Machine » Read the story

© 2019 The MathWorks, Inc. MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See mathworks.com/trademarks for
a list of additional trademarks. Other product or brand names may be trademarks or registered trademarks of their respective holders.

Anda mungkin juga menyukai