MCPcopy Index your code
hub / github.com/TorchSSL/TorchSSL / TSA

Function TSA

models/uda/uda_utils.py:19–33  ·  view source on GitHub ↗
(schedule, cur_iter, total_iter, num_classes)

Source from the content-addressed store, hash-verified

17
18
19def TSA(schedule, cur_iter, total_iter, num_classes):
20 training_progress = cur_iter / total_iter
21
22 if schedule == 'linear':
23 threshold = training_progress
24 elif schedule == 'exp':
25 scale = 5
26 threshold = math.exp((training_progress - 1) * scale)
27 elif schedule == 'log':
28 scale = 5
29 threshold = 1 - math.exp((-training_progress) * scale)
30 elif schedule == 'none':
31 return 1
32 tsa = threshold * (1 - 1 / num_classes) + 1 / num_classes
33 return tsa
34
35
36def consistency_loss(logits_s, logits_w, class_acc, it, ds, name='ce', T=1.0, p_cutoff=0.0, use_flex=False):

Callers 1

trainMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected