Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activation for BinaryNet #5

Open
ruizhoud opened this issue Feb 2, 2018 · 1 comment
Open

Activation for BinaryNet #5

ruizhoud opened this issue Feb 2, 2018 · 1 comment

Comments

@ruizhoud
Copy link

ruizhoud commented Feb 2, 2018

Hello,

I noticed that torch.nn.Hardtanh is used for activation functions in BinaryNet. This is meant to make the model trainable, as introduced in the BNN paper. However, in the inference phase (the validate() function in main_binary.py), shoudn't the activation function be changed to sign function so that the intermediate results are binary?

Thanks!

@roeemz
Copy link

roeemz commented Mar 19, 2018

Check out binarized_modules:
https://github.com/itayhubara/BinaryNet.pytorch/blob/master/models/binarized_modules.py#L76
and
https://github.com/itayhubara/BinaryNet.pytorch/blob/master/models/binarized_modules.py#L95

You will see that the input to each layer is Binarized anyway so as long as you use BinarizeConv2d or BinarizeLinear you are good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants