@KFrank ，Thank you for your kind help，
1.I use Rounding_output_c1 = torch.round(output_c1)
because I want to make my network’s output is integer,
and use these code to caculate my training_acc
 labels_float = labels.float()  #labels is not Decimal, labels size is [4,224,224]
running_corrects = torch.sum(Rounding_output_c1 == labels_float).float()
labels_size = labels.size(1) * labels.size(2) * 4
training_acc = running_corrects / labels_size
and if I don’t use Rounding_output_c1 = torch.round(output_c1),  training_acc will be 0.
2 I use loss.requires_grad = True   because when I debug my code I observed that  loss requires_grad is False if I don’t use this code It will get an error .
Traceback (most recent call last):
 File "F:/experiment_code/U-net/train_2.py", line 85, in <module>
 loss.backward()
 File "D:\Anaconda3\lib\site-packages\torch\tensor.py", line 107, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph)
File "D:\Anaconda3\lib\site-packages\torch\autograd\__init__.py", line 93, in backward
 allow_unreachable=True)  # allow_unreachable flag
RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn
my pytorch version is