Deep Learning in Simulink
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
Learn More
Featured Product
Deep Learning Toolbox
Up Next:
Related Videos:
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다: .
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- 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
- United Kingdom (English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)