Thank you so much for answering. I tried changing my loss function to cross entropy but I got an error:
RuntimeError: only batches of spatial targets supported (3D tensors) but got targets of dimension: 4

What does this mean?