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

PyTorch Implementation: Forward Pass #18

Open
killawhale2 opened this issue Feb 13, 2020 · 2 comments
Open

PyTorch Implementation: Forward Pass #18

killawhale2 opened this issue Feb 13, 2020 · 2 comments

Comments

@killawhale2
Copy link

First of all, thank you for sharing the PyTorch implementation, it's wonderful.
I've been going over the code and found this line:
binary_weights = binary_weights_no_grad.detach() - cliped_weights.detach() + cliped_weights
in the birealnet.py and was wondering what the purpose of this is for.
My best guess is that it's to merely allow the gradients to exist without actually changing the values of the binary weights, but some helpful clarification would be wonderful!

@CuauSuarez
Copy link

The purpose is that the "forward" value is going to be the binarized weight (binary_weights_no_grad) while the value for obtaining the gradient (the "backward" value) is the clamped weight (cliped_weights).

This trick is also used for the binary_activation for using a binarized value for the forward pass while using the approximation for the backward pass.

@ngunsu
Copy link

ngunsu commented Jun 18, 2020

binary_weights_no_grad is a floating-point tensor, sign(w) * scale. After the training is done, how can be converted to a binary weight?. I tried, in a naive way, to just use sign(w) without positive results. In essence, after using sign(w) over the trained weights, the network did not work anymore.

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

3 participants