Questions about inplace operation?

Why not use

binarize = lambda x: F.relu(x) * 2 - 1

The problem might be that you modify the input inplace without telling pytorch that the input is dirty. In forward you need to do this…

self.mark_dirty(input)

For more info, see here…