Binary Activation Function with Pytorch

This example could probably do, what you need.