error compiling ResNet50 Deep Learning HDL Toolbox Support Package
Show older comments
Hello,
I have a pretrained ResNet50 imported to a DAGNetwork object. The NN is working properly in matlab. However, I'm trying to implement it in a FPGA and I get the followong error while compiling. NN was imported using importTensorFlowNetwork and I'm trying to generate HDL with Deep Learning HDL Toolbox Support Package For Intel FPGA And SoC Devices (I was able to implement a sequential NN using a SeriesNetwork object and this tool):
Error in dnnfpga.apis.Workflow/compile
Error in generate_HDL_from_NN (line 18)
hW.compile;
Caused by:
Layer 'conv2_block1_3_conv': Input size mismatch. Size of input to this layer is different from the expected input size.
Inputs to this layer:
from layer 'conv2_block1_0_conv' (size 8(S) × 8(S) × 256(C) × 1(B))
Layer 'conv2_block1_add': Unconnected input. Each layer input must be connected to the output of another layer.
Layer 'conv2_block2_add': Unconnected input. Each layer input must be connected to the output of another layer.
Layer 'conv2_block3_add': Unconnected input. Each layer input must be connected to the output of another layer.
Layer 'conv3_block1_add': Unconnected input. Each layer input must be connected to the output of another layer.
Layer 'conv3_block2_add': Unconnected input. Each layer input must be connected to the output of another layer.
Layer 'conv3_block3_add': Unconnected input. Each layer input must be connected to the output of another layer.
Layer 'conv3_block4_add': Unconnected input. Each layer input must be connected to the output of another layer.
Layer 'conv4_block1_add': Unconnected input. Each layer input must be connected to the output of another layer.
Layer 'conv4_block2_add': Unconnected input. Each layer input must be connected to the output of another layer.
Layer 'conv4_block3_add': Unconnected input. Each layer input must be connected to the output of another layer.
Layer 'conv4_block4_add': Unconnected input. Each layer input must be connected to the output of another layer.
Layer 'conv4_block5_add': Unconnected input. Each layer input must be connected to the output of another layer.
Layer 'conv4_block6_add': Unconnected input. Each layer input must be connected to the output of another layer.
Layer 'conv5_block1_add': Unconnected input. Each layer input must be connected to the output of another layer.
Layer 'conv5_block2_add': Unconnected input. Each layer input must be connected to the output of another layer.
Layer 'conv5_block3_add': Unconnected input. Each layer input must be connected to the output of another layer.
Do you have any suggestion to solve this issue?
Thank you in advance
---------------------------
Software version:
Deep Learning HDL Toolbox Support Package For Intel FPGA And SoC Devices 21.2.4
Matlab R2021b Update 6 (9.11.0.2207237)
Ubuntu 20.04
---------------------------
Answers (2)
Hi Ruben,
For Resnet50 network, have you tried to download the Deep Learning Toolbox Model for ResNet-50 Network support pacakge?The Resnet50 network in this support package works together with Deep Learning HDL Toolbox:
There is also a ResNet-18 network support pacakge:
For the network you imported using importTensorFlowNetwork, could you contact MathWorks customer support and shared the network with customer support? It looks like the network is not correctly constructed in MATLAB. The error message on the "Unconnected input. Each layer input must be connected to the output of another layer" are generic MATLAB network connection errors. They are not specific to FPGA targeting.
Thanks,
Wang
6 Comments
Sivylla Paraskevopoulou
on 17 Apr 2023
Hi Ruben,
I think what Wang meant when he suggested to download the Deep Learning Toolbox Model for ResNet-50 Network support package, is to load ResNet50 from the support package instead of importing it.
If you have the support package installed, you can load the network by entering:
Then, you can generate HDL for net.
Sivylla Paraskevopoulou
on 17 Apr 2023
The displayed error mentions unconnected linputs. When you import the network from TensorFlow, you can check that all the layers are properly connected by using analyzeNetwork. There should be no errors or warnings showing up in Deep Learning Network Analyzer. Also all the layers of the imported network might not support HDL code generation. See Supported Networks, Layers, Boards, and Tools for all supported layers. The network layers might look the same, but the imported network might include custom layers or other layers that do not support HDL code generation.
It may be easier to add the additional desired layers to the MATLAB built-in ResNet50. MATLAB has excellent tools that make model surgery very easy, such as addLayers and connectLayers.
Rubén
on 17 Apr 2023
Wang Chen
on 17 Apr 2023
Hi Ruben,
It will be great if you can share your imported network to us, so we can take a look at it and see what is the cause of the issue. Could you contact MathWorks customer support and shared the network with customer support?
Alternatively, as Sivylla suggested, you could add the additional desired layers to the MATLAB built-in ResNet50 or ResNet18, using MATLAB tools like Deep Network Designer:
Thanks,
Wang
Rubén
on 17 Apr 2023
0 votes
5 Comments
Hi Ruben,
Thanks for sharing the network. After looking at your network, we identified that error you saw is caused by a bug in R2021b version. This bug is fixed in R2022b or later version of Deep Learning HDL Toolbox. It is possible for you to upgrade to a R2022b or R2023a version of MATLAB/Deep Learning HDL Toolbox?
Thanks,
Wang
Rubén
on 18 Apr 2023
Wang Chen
on 28 Apr 2023
Hi Ruben, the root cause of this bug is the pattern of zero padding layer (nnet.keras.layer.ZeroPadding2dLayer) followed by a group convolution layer, please see following bug report: https://www.mathworks.com/support/bugreports/2661508
This bug is fixed in R2022b.
If you cannot upgrade to R2022b, the work-around is to merge the zero padding into the group convolution layer. These two layers can be merged because the group convolution layer also has the padding options.
Thanks,
Wang
Rubén
on 3 May 2023
Categories
Find more on Prototype Deep Learning Networks on FPGA in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
