Would you mind sharing some code so it’s easier for me understand where bug appears?
Also, check if there are any NaNs in your data (via: torch.isnan(x).any()) before applying torch.svd. If you’re normalising your data check the variance is non-zero, because that’ll introduce a divide by zero error. And, I assume you’re doing all 1000 images in one go? So, you need to use torch.diag_embed(S) rather than torch.diag(S) instead!