MCPcopy Create free account
hub / github.com/JasonLSC/GSCodec_Studio / train

Method train

examples/simple_trainer.py:699–1098  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

697 return render_colors, render_alphas, info
698
699 def train(self):
700 cfg = self.cfg
701 device = self.device
702 world_rank = self.world_rank
703 world_size = self.world_size
704
705 # Dump cfg.
706 if world_rank == 0:
707 with open(f"{cfg.result_dir}/cfg.yml", "w") as f:
708 yaml.dump(vars(cfg), f)
709
710 max_steps = cfg.max_steps
711 init_step = 0
712
713 schedulers = [
714 # means has a learning rate schedule, that end at 0.01 of the initial value
715 torch.optim.lr_scheduler.ExponentialLR(
716 self.optimizers["means"], gamma=0.01 ** (1.0 / max_steps)
717 ),
718 ]
719 if cfg.pose_opt:
720 # pose optimization has a learning rate schedule
721 schedulers.append(
722 torch.optim.lr_scheduler.ExponentialLR(
723 self.pose_optimizers[0], gamma=0.01 ** (1.0 / max_steps)
724 )
725 )
726 if cfg.use_bilateral_grid:
727 # bilateral grid has a learning rate schedule. Linear warmup for 1000 steps.
728 schedulers.append(
729 torch.optim.lr_scheduler.ChainedScheduler(
730 [
731 torch.optim.lr_scheduler.LinearLR(
732 self.bil_grid_optimizers[0],
733 start_factor=0.01,
734 total_iters=1000,
735 ),
736 torch.optim.lr_scheduler.ExponentialLR(
737 self.bil_grid_optimizers[0], gamma=0.01 ** (1.0 / max_steps)
738 ),
739 ]
740 )
741 )
742
743 trainloader = torch.utils.data.DataLoader(
744 self.trainset,
745 batch_size=cfg.batch_size,
746 shuffle=True,
747 num_workers=4,
748 persistent_workers=True,
749 pin_memory=True,
750 )
751 trainloader_iter = iter(trainloader)
752
753 with self.get_profiler(self.writer) as prof:
754 self.profiler = prof if self.profiler_config.enabled else None
755
756 # Training loop.

Callers 1

mainFunction · 0.95

Calls 15

get_profilerMethod · 0.95
rasterize_splatsMethod · 0.95
step_profilerMethod · 0.95
evalMethod · 0.95
render_trajMethod · 0.95
sliceFunction · 0.90
total_variation_lossFunction · 0.90
getMethod · 0.80
add_imageMethod · 0.80
flushMethod · 0.80
stepMethod · 0.80

Tested by

no test coverage detected