MCPcopy Create free account
hub / github.com/TorchSSL/TorchSSL / calculate_mask

Method calculate_mask

models/softmatch/softmatch.py:253–260  ·  view source on GitHub ↗
(self, probs)

Source from the content-addressed store, hash-verified

251
252 @torch.no_grad()
253 def calculate_mask(self, probs):
254 max_probs, max_idx = probs.max(dim=-1)
255
256 # compute weight
257 mu = self.prob_max_mu_t
258 var = self.prob_max_var_t
259 mask = torch.exp(-((torch.clamp(max_probs - mu, max=0.0) ** 2) / (2 * var / 4)))
260 return max_probs.detach(), mask.detach()
261
262 @torch.no_grad()
263 def distribution_alignment(self, probs):

Callers 1

trainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected