This code is not fully cleaned-up yet, porting might not be trivial yet. Expect regular updates to improve upon this.
Train your own Binary Neural Networks (BNN) - networks trained with 1b weights and activations - in Theano / Lasagne. This code was used to train Binary Neural Networks, specifically for the BinarEye chip (reference coming up).
This code uses / is based on the lasagne/theano version of BinaryNet.
Running this code requires:
- Theano
- Lasagne
- A GPU with recent versions of CUDA and CUDNN
- pylearn2 for MNIST, SVHN and CIFAR-10
- The custom datasets for facedetection, ownerrecognition, anglerecognition and 10-face facerecognition can be found here:
Once you have all data sets local, you can run the following commands to start training:
- cd ./CIFAR10/; python cifar10.py -f 256
- cd ./MNIST/; python mnist.py -f 256
- cd ./SVHN/; python svhn.py -f 256
- cd ./train_anglerecognition_custom/; python AngleSense.py -f 256
- cd ./train_facedetection_custom/; python AngleSense.py -f 256
- cd ./train_facerecognition_custom/; python AngleSense.py -f 256
- cd ./train_ownerrecognition_custom/; python AngleSense.py -f 256
Where f is the number of filters in every layer (the width of every layer in the network). In BinarEye, f is constrained to either 64, 128 or 256.
The used datasets are built on existing datasets.
- facedetection, ownerdetection and facerecognition are built on a combination of mini-crops of backgrounds from Stanford and faces from LFW
- anglerecognition is built on cropped and aligned faces from AdienceFaces
All input images are rescaled to 32x32x3 input images in order to be processed by the BinarEye chip. Backgrounds are either 32x32 crops of larger images, or 32x32 rescales of larger sub-images.