pypose.optim.strategy.Constant¶
- class pypose.optim.strategy.Constant(damping=1e-06)[source]¶
Constant damping strategy used in the Levenberg-Marquardt (LM) algorithm.
- Parameters
damping (float, optional) – damping factor of LM optimizer. Default: 1e-6.
Example
>>> class PoseInv(nn.Module): ... def __init__(self, *dim): ... super().__init__() ... self.pose = pp.Parameter(pp.randn_SE3(*dim)) ... ... def forward(self, inputs): ... return (self.pose @ inputs).Log().tensor() ... ... device = torch.device("cuda" if torch.cuda.is_available() else "cpu") ... inputs = pp.randn_SE3(2, 2).to(device) ... invnet = PoseInv(2, 2).to(device) ... strategy = pp.optim.strategy.Constant(damping=1e-6) ... optimizer = pp.optim.LM(invnet, strategy=strategy) ... ... for idx in range(10): ... loss = optimizer.step(inputs) ... print('Pose loss %.7f @ %dit'%(loss, idx)) ... if loss < 1e-5: ... print('Early Stoping!') ... print('Optimization Early Done with loss:', loss.item()) ... break Pose loss 0.0000000 @ 0it Early Stoping! Optimization Early Done with loss: 9.236661990819073e-10
Note
More details about optimization go to
pypose.optim.LevenbergMarquardt()
.