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

tensor.sign? no backward? #25

Open
edwardzcl opened this issue Jul 9, 2020 · 4 comments
Open

tensor.sign? no backward? #25

edwardzcl opened this issue Jul 9, 2020 · 4 comments

Comments

@edwardzcl
Copy link

See https://github.com/itayhubara/BinaryNet.pytorch/blob/master/models/binarized_modules.py

image

I want to know what is the backward process of this function. Only use tensor.sign()? What is the backward values of it?

@hainingfang
Copy link

since it uses tensor.data = Binarize(tensor.data.org) in the code, so PyTorch won't record the grad op in the graph, in other words, no need to worry about the backward op, it won't happen at all.

@whubaichuan
Copy link

I think the gradient will be set to 1 because of the code

    def backward(ctx,grad_output):
        #STE 
        grad_input=grad_output.sign()
        return grad_input,None,None,None

@zouyingcao
Copy link

I think the gradient will be set to 1 because of the code

    def backward(ctx,grad_output):
        #STE 
        grad_input=grad_output.sign()
        return grad_input,None,None,None

There is a question that there is no grad_output.sign() in the current code version. Just grad_input=grad_output there. Is there any error about code update?

@whubaichuan
Copy link

I think the gradient will be set to 1 because of the code

    def backward(ctx,grad_output):
        #STE 
        grad_input=grad_output.sign()
        return grad_input,None,None,None

There is a question that there is no grad_output.sign() in the current code version. Just grad_input=grad_output there. Is there any error about code update?

No, because 1.sign() = 1

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

4 participants