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

Function one_hot_encoder

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

Source from the content-addressed store, hash-verified

84 print('[Statistics Information]\nFLOPs: {}\nParams: {}'.format(flops, params))
85
86def 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
102class DiceLoss(nn.Module):
103 def __init__(self, n_classes):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected