MCPcopy Create free account
hub / github.com/SLDGroup/MERIT / one_hot_encoder

Function one_hot_encoder

utils/utils.py:90–104  ·  view source on GitHub ↗
(input_tensor,dataset,n_classes = None)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected