I am following a source code corresponding to a paper where authors have trained the model to do a segmentation task. In the code, authors wrote:
if torch.cuda.is_available(): net.cuda() softMax.cuda() CE_loss.cuda() Dice_loss.cuda()
I don’t understand why the authors felt the need to send the loss functions to CUDA when the model has already been sent to the device? I have been using tensorflow in my past and I am new to pytorch, so I have trouble in understanding the device initialization for models and loss functions.