Hi Bigtree!



 bigtree:

So to output either 0 or 1 for each pixel, I made the following change (Add Sigmoid and binary the output):
             output = self.scratch.output_conv(...)
            pred = out > 0.75



This is your problem – the thresholding step is not usefully
differentiable, so it breaks the computation graph, leading
to your error.
It is perfectly appropriate (and in fact necessary) to train with
continuous predictions that have not been thresholded (or otherwise
converted to a discrete result).


During training, I use the loss function:
loss_f= nn.BCELoss()



As an aside, you a better off, for reasons of numerical stability,
using BCEWithLogitsLoss (and no final Sigmoid).
Best.
K. Frank