MathWorks - Mobile View
  • Sign In to Your MathWorks AccountSign In to Your MathWorks Account
  • Access your MathWorks Account
    • My Account
    • My Community Profile
    • Link License
    • Sign Out
  • Products
  • Solutions
  • Academia
  • Support
  • Community
  • Events
  • Get MATLAB
MathWorks
  • Products
  • Solutions
  • Academia
  • Support
  • Community
  • Events
  • Get MATLAB
  • Sign In to Your MathWorks AccountSign In to Your MathWorks Account
  • Access your MathWorks Account
    • My Account
    • My Community Profile
    • Link License
    • Sign Out

Videos and Webinars

  • MathWorks
  • Videos
  • Videos Home
  • Search
  • Videos Home
  • Search
  • Contact sales
  • Trial software
  Register to watch video
  • Description
  • Full Transcript
  • Related Resources

Deep Learning in Simulink

Emmanouil Tzorakoleftherakis, MathWorks

With MATLAB® R2020b, you can use the Deep Learning Toolbox™ block library as well as MATLAB Function block to simulate and generate code from trained deep learning models in Simulink®.

See how you can simulate deep learning networks in Simulink with control, signal processing, and sensor fusion components to assess the impact of your deep learning model on system-level performance. Learn more about using NVIDIA® GPUs to speed up the execution of your deep learning network model in Simulink.

As of R2020b release of MATLAB®, you can use the MATLAB Function block as well as the Deep Learning Toolbox™ block library to simulate and generate code from trained deep learning models in Simulink®. For example, to design a highway lane following system, you can use the deep learning blocks to create a Simulink subsystem that performs lane and vehicle detection, integrate this subsystem with a larger Simulink model that includes additional components such as the vehicle dynamics model, the lane following controller, sensor fusion and 3D visualization, and verify performance of the overall design through system-level simulation before deployment. Let’s see how we can create a subsystem that performs vehicle and lane detection in Simulink. The first thing we will need is a C++ compiler. We will also need the support packages that provide interfaces from MATLAB Coder™ and GPU coder™ to target-specific deep learning libraries. Finally, we assume that we have a pretrained lane detection network as well as a pretrained yolov2 vehicle detector stored in MATLAB files. In the Simulink model, we are reading from a traffic video file, and after the vehicle and lane detection parts we are displaying the traffic video again with lane and vehicle annotations. For lane detection, first we are resizing the video frames to match the input expected by the trained lane detection network. Next we will use the ‘Predict’ block from the deep learning block library to perform inference on the trained network. To link the block to the lane detector object we are providing the path to the appropriate MATLAB file. Another option here would be to use a MATLAB function. The predict block will output two lane boundaries represented by a parabolic equation with 3 parameters that are then transformed into lanes in image coordinates. For vehicle detection, we will use a MATLAB Function block to perform inference on the pretrained yolov2 vehicle detector. Inside the MATLAB Function block we will load the pretrained network, and call the detect method to get the bounding boxes and associated confidence scores. Next, we will specify the dimensions of the block outputs. The MATLAB Function block can also be used with other types of networks like LSTMs, and you can also use it to output activations from specific layers of the network. The last thing we need to do before we run the simulation, is to set the simulation target language to C++ in the model settings. Clicking the Run button will under the hood generate code from the Predict and MATLAB Function blocks and compile it for CPU-accelerated simulation. The output of the simulation displays the annotated traffic video as expected. Finally, you can also use GPU Coder with NVIDIA® GPUs to accelerate simulation of deep learning models in Simulink. To configure the model for GPU Acceleration, check the ‘GPU Acceleration’ box under Simulation Target in the Model Settings. Once the system design is verified in simulation, you can generate code from the Simulink model for deployment. You can use Simulink Coder™, Embedded Coder® or GPU Coder to generate C++ or CUDA code and deploy deep learning networks on Intel®, ARM®, or NVIDIA platforms.

Related Products

  • Deep Learning Toolbox
  • GPU Coder
  • Simulink

Learn More

Deep Learning in Simulink for NVIDIA GPUs: Generate CUDA Code Using GPU Coder (3:29)

Feedback

Featured Product

Deep Learning Toolbox

  • Request Trial
  • Get Pricing

Up Next:

45:19
Enabling Project-Based Learning with MATLAB, Simulink, and...

Related Videos:

42:22
Enabling Project-Based Learning with MATLAB and Simulink
4:45
Run a Simulink Model on Zynq: Exploring the Simulink Model...
12:33
Simulink for Work Groups Using Simulink Projects
31:03
Utilization of Simulink Verification and Validation and...

View more related videos

MathWorks - Domain Selector

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

Select web site

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文Chinese
    • English
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

  • Contact sales
  • Trial software

Explore Products

  • MATLAB
  • Simulink
  • Student Software
  • Hardware Support
  • File Exchange

Try or Buy

  • Downloads
  • Trial Software
  • Contact Sales
  • Pricing and Licensing
  • How to Buy

Learn to Use

  • Documentation
  • Tutorials
  • Examples
  • Videos and Webinars
  • Training

Get Support

  • Installation Help
  • Answers
  • Consulting
  • License Center
  • Contact Support

About MathWorks

  • Careers
  • Newsroom
  • Social Mission
  • Contact Sales
  • About MathWorks

MathWorks

Accelerating the pace of engineering and science

MathWorks is the leading developer of mathematical computing software for engineers and scientists.

Discover…

  • Select a Web Site United States
  • Patents
  • Trademarks
  • Privacy Policy
  • Preventing Piracy
  • Application Status

© 1994-2021 The MathWorks, Inc.

  • Facebook
  • Twitter
  • Instagram
  • YouTube
  • LinkedIn
  • RSS

Join the conversation

This website uses cookies to improve your user experience, personalize content and ads, and analyze website traffic.  By continuing to use this website, you consent to our use of cookies.  Please see our Privacy Policy to learn more about cookies and how to change your settings.