-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add parameter metadata to the trainer schema. #2224
Conversation
2d43cba
to
76318a8
Compare
ludwig/schema/optimizers.py
Outdated
@@ -354,13 +355,14 @@ class GradientClippingConfig(BaseMarshmallowConfig): | |||
clipvalue: Optional[float] = FloatRange(default=None, allow_none=True, description="") | |||
|
|||
|
|||
def GradientClippingDataclassField(default={}, allow_none=True, description="TODO"): | |||
def GradientClippingDataclassField(description: str, default: Dict): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would still keep {}
as the default value for default
so it's visually clear that in the case of GradientClippingDataclassField
an empty dict is valid (whereas e.g. for OptimizerDataclassField
you have to at least provide a type
inside the dict)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added back the default value for default
for now.
Outside of this PR, we should consider removing the default values for marshmallow field function arguments. This will make some of the marshmallow unit tests more verbose, but it ensures that the field's parameters (default, description, etc.) are defined in one location, at the point of instantiation. For example, right now for OptimizerDataclassField
, we declare the default
in two places -- as a function parameter default via the marshmallow field definition, as well as at the point of instantiation in ECDTrainerConfig
.
Here's what I'm thinking:
- Always include
description
anddefault
as required arguments so that it's impossible to instantiate a marshmallow field without explicitly specifying thedescription
anddefault
. This setup ensures that the defaults and descriptions are concisely listed where parameters are declared, i.e.ECDTrainerConfig
. - Include other arguments like
allow_none
in the marshmallow field only if we want this to be able to be configured differently across different instances of the field. For example, we should removeallow_none
from the list of parameters forGradientClippingDataclassField
since it's alwaysTrue
. - Use
ParameterMetadata
to contain all other "optional" information pertaining to the field. Eventually, this will also be a required argument.
See also, why default arguments are bad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed on all counts!
No description provided.