Register, Validate, and Deploy Custom Natural Logarithm Layer Network to FPGA
This example shows how to register, validate, and deploy a custom natural logarithm (log) layer network by using Deep Learning HDL Toolbox™. To deploy the network with the custom natural logarithm (log) layer:
Register the custom natural logarithm log) layer by using the
registerCustomLayer
method.Validate the custom natural logarithm (log) layer by generating a custom layer verification model.
Generate a custom bitstream.
To retrieve the prediction results from the deployed custom layer network, use MATLAB®.
Create a Deep Learning Processor Configuration
To generate a custom processor configuration, use the dlhdl.ProcessorConfig
object. The generated deep learning processor configuration object has a custom module that contains the preconfigured custom layers. Save the deep learning processor configuration to a variable hPC
.
hPC = dlhdl.ProcessorConfig
Register Custom Layer and Model
To register an instance of the custom layer and custom layer Simulink® model use the registerCustomLayer
method. Deep Learning HDL Toolbox™ uses the Simulink® model to generate a verification model for the custom layer.
hLogLayer = LogLayer('customLog') registerCustomLayer(hPC,Layer = hLogLayer, Model = 'dnnfpgaLogLayerModel.slx')
The custom deep learning processor configuration has a Log layer under the custom processing module. The custom natural logarithm (log) layer is enabled by default for the bitstream generation.
Generate Verification Model for Custom Layer
Generate a verification model for your custom layer by using the openCustomLayerModel
method. Generate a test network and a test image for your custom layer network by specifying blank arguments for the Network
and InputImages
arguments of the openCustomLayerModel
method. The size of the test image matches the input layer size of the created test network.
openCustomLayerModel(hPC)
The openCustomLayerModel
method generates a verification model file called dnnfpgaCustomLayerVerificationModel.slx
for your custom layer.
Simulate and Validate Custom Layer Model
Before you verify your custom layer model by using the verifyCustomLayerModel
method, open the dnnfpgaCustomLayerVerificationModel.slx
verification model. The verifyCustomLayerModel
verifies the functionality of the custom layer and prediction accuracy of the network which has the custom layer.
verifyCustomLayerModel(hPC)
Generate Custom Bitstream
Generate a custom bitstream that has the name myCustomLayer.bit
by using the dlhdl.buildProcessor
function. Save the generated bitstream to the myCustomLayer_prj
folder.
dlhdl.buildProcessor(hPC,ProjectFolder = 'myCustomLayer_prj',ProcessorName ='myCustomLayer');
See Also
dlhdl.Workflow
| dlhdl.ProcessorConfig
| registerCustomLayer
| openCustomLayerModel
| verifyCustomLayerModel
| dlhdl.buildProcessor