Git Product home page Git Product logo

maxwellwjj / redeye_sim Goto Github PK

View Code? Open in Web Editor NEW

This project forked from julianyg/redeye_sim

0.0 1.0 0.0 26.95 MB

RedEye is a vision sensor designed to execute early stages of a deep convolutional neural network (ConvNet) in the analog domain. This repo is a modification of Caffe to train, simulate and visualize analog ConvNet processing under noise vs. energy tradeoffs.

Makefile 1.33% CMake 2.85% HTML 0.19% CSS 0.25% C++ 78.00% Shell 0.72% Python 10.14% Cuda 5.64% MATLAB 0.87% M 0.01%

redeye_sim's Introduction

#redeye_sim

RedEye is a vision sensor designed to execute early stages of a deep convolutional neural network (ConvNet) in the analog domain. This repo is a modification of Caffe for three main goals:

  • Simulate and visualize the noise vs. energy tradeoffs of analog ConvNet processing
  • Train and test RedEye-specific ConvNets
  • Build RedEye-ConvNet programs to interface with RedEye hardware (PRIVATE).

redeye_sim Modifications to Caffe

  • Gaussian Noise Layer: Parameterized with SNR, this layer simulates the signal infidelity of analog processing.
  • Uniform Noise Layer: Parameterized with SNR, this layer uses uniform noise to simulate the signal infidelity of the quantization of the analog-to-digital converter.
  • Quantization Layer: Parameterized with bits, this layer truncates data to simulate the quantization of the analog-to-digital converter.
  • Weight Digitization: This represents the bit-resolution of the of the fixed-point model weights used in the mixed-signal multiply-accumulate unit.
  • (Un)Gamma: Converts nonlinear input pixel values into linear luminance values.

Getting Started

  • You can either choose to use the caffe source included in redeye_sim, or download and replace the redeye_sim/caffe directory with the latest caffe source. For the latter choice, execute redify.sh under the scripts directory to add redeye_sim modifications.
  • Copy the makefile and config files from redeye_sim/configs/caffe to the redeye_sim/caffe directory.
  • Call make redeye command under the root redeye_sim directory.
  • Download the ImageNet dataset. Execute create_lmdb.sh to generate lmdb files for train and validation.
  • Download the pre-trained GoogLeNet caffemodel. Note: keep paths in data.config consistent when making data and run workflow.

Tuning and Testing

redeye_sim/simulation contains workflows to train the models (tune.py) and generates statistics (validate.py) for their performance. The workflows automatically inject noise layers to existing models, simulating analog noise behavior. Each workflow sweeps through a range of given noise SNRs, configured as follows:

  • Configure datapath directories, batch sizes, and data layer noise in configs/data.config. Recommended: use soft links for large data files.
  • Configure parameter intervals and prototxt templates in configs/run.config.
    • Specify the sweeping interval of Gaussian noise “gaussian_intvl” and uniform noise “uniform_intvl”, which represents circuit noise and ADC noise, respectively.
    • Specify the digitization bit-resolution “digitization_bits” of fixed-point weights.
    • Specify the depth (number of convolution layers) “depth” of analog execution.

redeye_sim/simulation also contains a workflow.py to procedurally train and test models in the SNR ranges. An example run of the complete workflow: under /simulation, execute python workflow.py --test_iter 500 --tune_iter 12000 --dest ../stats/test.csv --g 15,30 --q 15,25. This will sweep the SNR space and run fine tune for each noise-contaminated model for 12000 iterations, write results to test.csv, and save the test.png plot under plots folder. After too many runs, you can run /tools/cleaner.sh to clean up the messy .prototxt’s and .caffemodel’s if you do not need them anymore. (Keep them if you want to save time running later)

Limitations & Assumptions

  • The training data for simulation does not account for real-world image signal effects, e.g., over-exposure, white-balance.
  • The simulation does not include circuit non-idealities, e.g., offset, gain, signal decay.
  • Energy estimates for timing circuitry and signal propagation are not included.

Common Compilation Errors

If you are not using Makefile and Makefile.config under configs, here are some common errors that may occur:

  • Cannot find arrayobject.h or Python.h: look in site-packages instead of dist-packages, or /usr/local/lib instead of /usr/lib
  • Cannot find cblas.h: Modify the following lines in Makefile.config: (The BLAS_INCLUDE ?= in else statement, modify the path to your actual path that contains cblas.h. This path can be found by unix command find / -name cblas.h)
		ifneq (,$(findstring version: 6,$(XCODE_CLT_VER)))
			BLAS_INCLUDE ?= /System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/
			LDFLAGS += -framework Accelerate
		else
			BLAS_INCLUDE ?= /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/Headers/
			#LDFLAGS += -framework vecLib
			LDFLAGS += -framework Accelerate
		endif
  • Cannot load image _caffe.so: Ensure that DYLD_LIBRARY_PATH contains ~/caffe/build/lib, PYTHONPATH contains ~/caffe/python, and Makefile contains libc++11. Ensure that libc++11 is correctly set in CXXFLAGS and NVCCFLAGS. These changes should be made in Makefile and Makefile.config under configs/caffe.

If importing python results in a segfault, you are not using the right python for which caffe is installed. This is usually /usr/bin/python.

License

This repo is distributed for free usage.

redeye_sim's People

Contributors

julianyg avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.