Skip to content

Configuring partial functions #11

Description

@JIy3AHKO

In some scenarios I want the result of cfn.Config, to be a partial function. E. g.:

adamw = cfn.Config(
   functools.partial,
   torch.optim.AdamW, 
   lr=1e-3,
   weight_decay=0.01
) 

@cfn.config(optimizer=adamw)
def train(optimizer: Callable):
    model = Model()
    opt = optimizer(model.params())
    ...

Should we make some shortcut for such scenarios? Since with this implementation it wouldn't be possible to change the class of adamw (we have no support for *args override yet). The shortcut could look like:

optimizer = cfn.partial_config(torch.optim.AdamW, lr=1e-3, weight_decay=0.01)

@cfn.config(optimizer=optimizer)
def train(optimizer: Callable):
    model = Model()
    opt = optimizer(model.params())
    ...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions