(input_tensor,dataset,n_classes = None)
| 84 | print('[Statistics Information]\nFLOPs: {}\nParams: {}'.format(flops, params)) |
| 85 | |
| 86 | def one_hot_encoder(input_tensor,dataset,n_classes = None): |
| 87 | tensor_list = [] |
| 88 | if dataset == 'MMWHS': |
| 89 | dict = [0,205,420,500,550,600,820,850] |
| 90 | for i in dict: |
| 91 | temp_prob = input_tensor == i |
| 92 | tensor_list.append(temp_prob.unsqueeze(1)) |
| 93 | output_tensor = torch.cat(tensor_list, dim=1) |
| 94 | return output_tensor.float() |
| 95 | else: |
| 96 | for i in range(n_classes): |
| 97 | temp_prob = input_tensor == i |
| 98 | tensor_list.append(temp_prob.unsqueeze(1)) |
| 99 | output_tensor = torch.cat(tensor_list, dim=1) |
| 100 | return output_tensor.float() |
| 101 | |
| 102 | class DiceLoss(nn.Module): |
| 103 | def __init__(self, n_classes): |
nothing calls this directly
no outgoing calls
no test coverage detected