Convolutional Neural Network ExampleΒΆ

group CNNExample

Refer riscv_nnexamples_cifar10.cpp../../_images/CIFAR10_CNN.png

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.

Variables Description:

  • conv1_wt, conv2_wt, conv3_wt are convolution layer weight matrices

  • conv1_bias, conv2_bias, conv3_bias are convolution layer bias arrays

  • ip1_wt, ip1_bias point to fully-connected layer weights and biases

  • input_data points to the input image data

  • output_data points to the classification output

  • col_buffer is a buffer to store the im2col output

  • scratch_buffer is used to store the activation data (intermediate layer outputs)

NMSIS DSP 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