-
-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Labels
enhancementNew feature or requestNew feature or request
Description
In this example
from jsonargparse import ArgumentParser, CLI
import torch
from typing import Callable
from dataclasses import dataclass
@dataclass
class Foo:
opt: Callable[[torch.nn.Parameter], torch.optim.Optimizer]
parser = ArgumentParser()
parser.add_class_arguments(Foo)
args = parser.parse_args()
print(args)
# python script.py --opt torch.optim.Adam
How would I skip the lr
?
I tried both:
parser.add_class_arguments(Foo, skip={"opt.lr"})
parser.add_class_arguments(Foo, skip={"opt.init_args.lr"})
but they do nothing.
I noticed that:
opt: Callable[[torch.nn.Parameter, float], torch.optim.Optimizer]
will work assuming that the lr
is the second positional argument of all optimizers, which might not be always true.
Thanks for the help!
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request