Handling singular matrices when backprop

Hey guys!

I am currently running into the following problem:
I’ll get the
RuntimeError: inverse_cuda: For batch 0: U(1,1) is zero, singular U.
message, when computing lots of determinants during the forward pass. Do you know how to tackle this problem appropriately? I am aware of the fact that the matrices have to be non-singular in order to compute its gradients - but how to make sure that only non-singular matrices are considered when backwarding?

Thanks a lot in advance!