MCPcopy Create free account
hub / github.com/OpenImagingLab/4DSloMo / get_expon_lr_func

Function get_expon_lr_func

utils/general_utils.py:30–63  ·  view source on GitHub ↗

Copied from Plenoxels Continuous learning rate decay function. Adapted from JaxNeRF The returned rate is lr_init when step=0 and lr_final when step=max_steps, and is log-linearly interpolated elsewhere (equivalent to exponential decay). If lr_delay_steps>0 then the learning rat

(
    lr_init, lr_final, lr_delay_steps=0, lr_delay_mult=1.0, max_steps=1000000
)

Source from the content-addressed store, hash-verified

28 return resized_image.unsqueeze(dim=-1).permute(2, 0, 1)
29
30def get_expon_lr_func(
31 lr_init, lr_final, lr_delay_steps=0, lr_delay_mult=1.0, max_steps=1000000
32):
33 """
34 Copied from Plenoxels
35
36 Continuous learning rate decay function. Adapted from JaxNeRF
37 The returned rate is lr_init when step=0 and lr_final when step=max_steps, and
38 is log-linearly interpolated elsewhere (equivalent to exponential decay).
39 If lr_delay_steps>0 then the learning rate will be scaled by some smooth
40 function of lr_delay_mult, such that the initial learning rate is
41 lr_init*lr_delay_mult at the beginning of optimization but will be eased back
42 to the normal learning rate when steps>lr_delay_steps.
43 :param conf: config subtree 'lr' or similar
44 :param max_steps: int, the number of steps during optimization.
45 :return HoF which takes step as input
46 """
47
48 def helper(step):
49 if step < 0 or (lr_init == 0.0 and lr_final == 0.0):
50 # Disable this parameter
51 return 0.0
52 if lr_delay_steps > 0:
53 # A kind of reverse cosine decay.
54 delay_rate = lr_delay_mult + (1 - lr_delay_mult) * np.sin(
55 0.5 * np.pi * np.clip(step / lr_delay_steps, 0, 1)
56 )
57 else:
58 delay_rate = 1.0
59 t = np.clip(step / max_steps, 0, 1)
60 log_lerp = np.exp(np.log(lr_init) * (1 - t) + np.log(lr_final) * t)
61 return delay_rate * log_lerp
62
63 return helper
64
65def strip_lowerdiag(L):
66 uncertainty = torch.zeros((L.shape[0], 6), dtype=torch.float, device="cuda")

Callers 1

training_setupMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected