Skip to content

Commit c928535

Browse files
dannyfriargpleiss
andauthored
Accept closure argument in NGD optimizer step (#2118)
* Accept closure argument in NGD optimizer `step` Make this consistent with the base optimizer class * Update NGD docs. Co-authored-by: Geoff Pleiss <[email protected]>
1 parent 554526e commit c928535

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

gpytorch/optim/ngd.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
from typing import Iterable, Union
3+
from typing import Callable, Iterable, Optional, Union
44

55
import torch
66

@@ -28,8 +28,13 @@ def __init__(self, params: Iterable[Union[torch.nn.Parameter, dict]], num_data:
2828
super().__init__(params, defaults=dict(lr=lr))
2929

3030
@torch.no_grad()
31-
def step(self) -> None:
32-
"""Performs a single optimization step."""
31+
def step(self, closure: Optional[Callable] = None) -> None:
32+
"""
33+
Performs a single optimization step.
34+
35+
(Note that the :attr:`closure` argument is not used by this optimizer; it is simply included to be
36+
compatible with the PyTorch optimizer API.)
37+
"""
3338
for group in self.param_groups:
3439
for p in group["params"]:
3540
if p.grad is None:

0 commit comments

Comments
 (0)