MatthieuCourbariaux / BinaryNet

Training Deep Neural Networks with Weights and Activations Constrained to +1 or -1
BSD 3-Clause "New" or "Revised" License
1.04k stars 346 forks source link

could you share your cifar-10 test code #12

Closed skyfuturesky closed 7 years ago

skyfuturesky commented 7 years ago

Hello, I am working no cifar-10 binay network. I used your cifar-10 training code, and then I wrote my own testing code for ciffar-10. Generally I binarized conv2d layer weights and dense layer weights, but after binarizing conv2d layer weights, I couldn't get the right results. (I used deterministic to binarize) So I am wondering am I understanding BNN correctly, or is it possible for you to share your cifar-10 test code? Thank you very much!

ofirliba commented 7 years ago

hi skyfuturesky , did you succeed to create a runtime code for cifar10? If you could share your code as well as cifar10 train parameters file , I would appreciate it very much!

thank you!

skyfuturesky commented 7 years ago

Hello, thank you so much for your reply. Actually I have already solved the problem. I can create a runtime code for cifar10, it turns out to be an issue in binary_net.py. In the line 165, I added the following code segment:

def get_output_for(self, input, deterministic=False, **kwargs):

    self.Wb = binarization(self.W, self.H, self.binary, deterministic, self.stochastic, self._srng)
    Wr = self.W
    self.W = self.Wb

    rvalue = super(Conv2DLayer, self).get_output_for(input, **kwargs)

    self.W = Wr

    return rvalue

Now testing result is correct.

Best, Yuteng

ofirliba commented 7 years ago

hi, Thanks for your replay. cifar10.py in train folder works fine.

Sorry for the miss understanding ,but what I'm looking for is cifar10 runtime ( like mnist.py in runtime folder) code using xnor/baseline/theano kernels in Dense and conv2D layers. if you have this code it would be wonderful.

do you have any idea if those optimized kernels can be also implemented in conv2DLayer?

thanks, Ofir

skyfuturesky commented 7 years ago

In runtime folder, only mnist.py is provided. You are right, there is no conv2DLayer in runtime folder, what I did was to modify the code in training folder to run testing.