Convolutional Neural Network Example
- group CNNExample
- Description:
Demonstrates a convolutional neural network (CNN) example with the use of convolution, ReLU activation, pooling and fully-connected functions.
- Model definition:
The CNN used in this example is based on CIFAR-10 example from Caffe [1]. The neural network consists of 3 convolution layers interspersed by ReLU activation and max pooling layers, followed by a fully-connected layer at the end. The input to the network is a 32x32 pixel color image, which will be classified into one of the 10 output classes. This example model implementation needs 32.3 KB to store weights, 40 KB for activations and 3.1 KB for storing the
im2col
data.
Refer riscv_nnexamples_cifar10.c
- Variables Description:
conv1_wt
,conv2_wt
,conv3_wt
are convolution layer weight matricesconv1_bias
,conv2_bias
,conv3_bias
are convolution layer bias arraysip1_wt
, ip1_bias point to fully-connected layer weights and biasesinput_data
points to the input image dataoutput_data
points to the classification outputcol_buffer
is a buffer to store theim2col
outputscratch_buffer
is used to store the activation data (intermediate layer outputs)
- NMSIS NN Software Library Functions Used:
riscv_convolve_HWC_q7_RGB()
riscv_convolve_HWC_q7_fast()
riscv_relu_q7()
riscv_maxpool_q7_HWC()
riscv_avepool_q7_HWC()
riscv_fully_connected_q7_opt()
riscv_fully_connected_q7()
- [1] https://github.com/BVLC/caffe