MCPcopy Create free account
hub / github.com/ChunmingHe/WS-SAM / get_coef

Function get_coef

utils/utils.py:6–26  ·  view source on GitHub ↗
(iter_percentage, method)

Source from the content-addressed store, hash-verified

4from thop import clever_format
5
6def get_coef(iter_percentage, method):
7 if method == "linear":
8 milestones = (0.3, 0.7)
9 coef_range = (0, 1)
10 min_point, max_point = min(milestones), max(milestones)
11 min_coef, max_coef = min(coef_range), max(coef_range)
12 if iter_percentage < min_point:
13 ual_coef = min_coef
14 elif iter_percentage > max_point:
15 ual_coef = max_coef
16 else:
17 ratio = (max_coef - min_coef) / (max_point - min_point)
18 ual_coef = ratio * (iter_percentage - min_point)
19 elif method == "cos":
20 coef_range = (0, 1)
21 min_coef, max_coef = min(coef_range), max(coef_range)
22 normalized_coef = (1 - np.cos(iter_percentage * np.pi)) / 2
23 ual_coef = normalized_coef * (max_coef - min_coef) + min_coef
24 else:
25 ual_coef = 1.0
26 return ual_coef
27
28
29def cal_ual(seg_logits, seg_gts):

Callers 1

trainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected