The threshold operation would create a zero gradient on almost everywhere, which is most likely why the model isn’t training.
The usual loss functions expect the model output to contain the logits, log-probabilities, etc. and apply a “smooth” function internally, such as F.log_softmax.