Closed sedol1339 closed 2 months ago
This is indeed possible with a FieldReference
.
model_kwargs = config_dict.ConfigDict()
model_kwargs.activation_dropout = config_dict.FieldReference(None, field_type=float)
...
This will now have default value None
, but will allow overrides with floats (while still guarding against other types incompatible with float
).
This is not a bug report, but is this possible to allow None values for float fields?
For example, I have
kwargs
field that stores kwarg-value pairs for Wav2vec2 constructor. Some kwarg, for exampleactivation_dropout
may be either float or None (use a value from loaded model checkpoint). None equivalent to the absence of this kwarg.The config default value is None, and I want to override it with float in the command line:
However, it says cannot override None type.
Actually, I can specify np.nan as default. But the Wav2vec2 does not accept np.nan, so I need to manyally convert np.nan to None before calling the constructor, which is awkward. Is there a solution?