Skip to content

Commit

Permalink
move N inside step
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul-goel committed Oct 2, 2024
1 parent dc19061 commit 5186c47
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/simple_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ def train(self):
# optimize
for optimizer in self.optimizers.values():
if cfg.visible_adam:
optimizer.step(visibility_mask, gaussian_cnt)
optimizer.step(visibility_mask)
else:
optimizer.step()
optimizer.zero_grad(set_to_none=True)
Expand Down
5 changes: 3 additions & 2 deletions gsplat/optimizers/selective_adam.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@ class SelectiveAdam(torch.optim.Adam):
>>> loss.backward()
>>> # Optimization step with selective updates
>>> optimizer.step(visibility=visibility_mask, N=N)
>>> optimizer.step(visibility=visibility_mask)
"""

def __init__(self, params, eps, betas):
super().__init__(params=params, eps=eps, betas=betas)

@torch.no_grad()
def step(self, visibility, N):
def step(self, visibility):
N = visibility.numel()
for group in self.param_groups:
lr = group["lr"]
eps = group["eps"]
Expand Down

0 comments on commit 5186c47

Please sign in to comment.