Skip to content

widmannthomas/convolutional_neural_network_energy_improvement

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Analyzing the impact of pruning on CNNs in TinyML applications on energy consumption.

A framework for measuring the energy consumption of a MCU during the execution of pruned TensorFlow-Lite models.

This framework provides Jupyter Notebooks to create LeNet-5 like pruned convolutional neural networks with different compression rates. Furthermore, the framework provides Jupyter Notebooks to convert the models into the required TensorFlow-Lite format. For measuring the energy consumption during execution, the framework provides a Python script to generate current traces. For analyzation purpose, the framework includes scripts to analyze the measured current traces.

The framework supports the Raspberry Pi Pico which uses an Arm-Cortex M0+ architecture.

Background

This project was developed in the course of a bachelor thesis. The goal was to answer the following research questions:

  • RQ1: How does unstructured pruning affect energy consumption?
  • RQ2: How does structured pruning affect energy consumption?

Model creation

The framework on one hand, provides Jupyter Notebooks to create pruned models from scratch and on the other hand, it provides pre-trained and pruned models with different compression rates and pruning approaches.

Pre-trained models

All pre-trained models are located in Models. The models are saved as .h5 files and start with a prefix indicating the compression rate. Section Create TFL model in this Jupyter Notebook is used to convert the pre-trained model into a TFL model required by the RPP.

Pruning

To create pruned models from scratch, the framework provides the following Jupyter Notebook.

Execution and energy measurement

For tracing the current consumption of the RPP during execution, the framework provides the following Python script. The script automatically executes the classification on the RPP and traces the current in parallel. After tracing, the script saves the measured data in .csv files.

Execution

The framework provides a C++ environment that allows to easily send image data to the Raspberry Pi Pico, do the classification and receive the probabilities.

Compilation

The project uses cmake as build environment.

Preparation: Before you start building this project, make sure you have the required tool chain installed.

sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib

Furthermore, you have to clone the pico-sdk repository and set the PICO_SDK_PATHenvironemt variable properly. A good step-by-step manual can be found here: PICO-SDK

Build:

  1. pull this project
git clone https://github.com/widmannthomas/convolutional_neural_network_energy_improvement.git
cd convolutional_neural_network_energy_improvement
  1. init git submodules
git submodule init
git submodule update
  1. create a build directory
mkdir build
cd build
  1. run cmake
cmake ..
  1. build sub-modules
cd src/mnist
make
  1. Copy binary to Raspberry Pi Pico Volume
cp mnist.uf2 <RPP TARGET>

Experiment setup

The following images are showing the experiment setup using the Raspberry Pi Pico.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published