Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper type hint for init method in class MNISTLitModule(LightningModule) #638

Open
cnjackhu opened this issue Apr 15, 2024 · 0 comments
Open

Comments

@cnjackhu
Copy link

cnjackhu commented Apr 15, 2024

init method of the class MNISTLitModule(LightningModule):

    def __init__(
        self,
        net: torch.nn.Module,
        optimizer: torch.optim.Optimizer,
        scheduler: torch.optim.lr_scheduler,
        compile: bool,
    ) -> None:

But actually the 'optimizer' and 'scheduler' we pass from a functools.partial, So does the Proper type hint is torch.optim.Optimizer, and torch.optim.lr_scheduler?

The file from model/mnist.yaml

optimizer:
  _target_: torch.optim.Adam
  _partial_: true
  lr: 0.001
  weight_decay: 0.0
scheduler:
  _target_: torch.optim.lr_scheduler.ReduceLROnPlateau
  _partial_: true
  mode: min
  factor: 0.1
  patience: 10
@cnjackhu cnjackhu changed the title does the partial type is torch.optim.Optimizer? Proper type hint for init method in class MNISTLitModule(LightningModule) Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant