Skip to content

MarinVukosav/Binary-Neural-Network-Keras

 
 

Repository files navigation

Binary-Neural-Network-Keras

A Keras code on Binary Neural Networks

Files to run in this order
Step 1: Run BNN_full_binary_io.py
This will give you your training for a Fully Connected 784-512-512-10 MLP layer. Binarization fo final weights is done at the end of training. Please edit the code for the binarization of your layers, if you added more layers
Step 1.1: Run Mnist_cnn.py
This will run the CNN model. BatchNorm and dropout has been commented out

Updated:

Step 2: Go into models folder. Run weight_extract_cnn.py (Run this if you ran mnist_cnn.py)
This will give you your binarized weights and conv layers on your final trained mode constrained to -1 and +1
Please edit the code for the binarization of your layers.

Step 3: (Results_validate folder) Either run BNN_new_train.py for evaluation of your saved weights loaded into a new model
OR
BNN_train_fun.py to test the trained results on real-time to see whether the model is able to predict your results

Note: Please Edit your PATH files

Miscellanous files (Do not Remove):

  • activations.py
  • binary_layers.py

(Results_validate Folder)

  • bnn_ip_binary.py (This is for fun to visualize the actual binarization of the input images)

If you are having trouble with Tenserflow installation, try using python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.5.0-py3-none-any.whl Also, it works only with python 3.4 - 3.6 and tensorflow version 1.5

Releases

No releases published

Packages

No packages published

Languages

  • Verilog 62.6%
  • Python 37.4%