Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[python-package][R-package] load parameters from model file (fixes #2613) #5424
[python-package][R-package] load parameters from model file (fixes #2613) #5424
Changes from all commits
7399fe1
02ca63a
c81f768
2ea2c29
b33d6a0
c7a6a22
f43934e
edf11fc
7761124
26ba91f
ec113c0
39c7a8c
0e6591b
d4e781b
c574a4a
483a3f4
4ab5dd4
bd4eec0
9a00fde
de6ef8a
2cec692
f066dba
db36cb9
9467814
339bb1c
4cbf477
6667771
17ad0c1
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
In this code block, there are two sources of parameter values:
params
keyword argument from the constructorI think that in the R and Python packages, wherever those conflict, the value passed through the keyword argument
params
should be preferred. But I'd like to hear your and @StrikerRUS 's opinions before you make any changes.Why we might want to support this behavior
That's consistent with how the R and Python packages treat the
params
argument generally (#4904 (comment)).And it'd be useful for non-Dask distributed training (for example), where some of the parameters like
machines
might change between the training run that produced an initial model and another one that performs training continuation.Why we might not want to support this behavior
I believe that the R and Python packages already ignore passed-in
params
if you're creating aBooster
from a model file.So maybe we want to continue to ignore them until a specific user report or reproducible example demonstrates that it's a problem or surprising.
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 prefer ignoring them, since they won't be used by the loaded booster and it could cause confusion. We can raise a warning when passing both params and model_file to the Booster constructor to make this more evident. When using the loaded booster as init model users can override the parameters for the new iterations in the train function, so that should be enough.
I haven't done much incremental learning so I hadn't given much thought to this haha, please feel free to correct me.
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 strongly believe we need a warning for users here.
And I think it's better to override loaded params from model string by the params passed in via
kwargs
.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.
Sure I can add the warning. What would be an example use case for overriding the parameters from the model file when loading the booster?
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.
Anything around continued training might result in loading a model from a file and then performing additional training with different parameters.
For examples:
machines
(since the IP addresses of machines used for distributed training might be different from when the model file was created)num_leaves
orlearning_rate
when performing an update like "train a few more iterations on newly-arrived data" (see my explanation in this Stack Overflow answer)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.
But I'm struggling to understand when
Booster.update
would be called on a model loaded from file. It requires a bit of setup like defining the training set, and if you pass the training set to the constructor it takes a different path where it calls BoosterCreate with only the training set and the parameters.The other case would be passing it to lgb.train as init_model and that already allows you to define the parameters for the new iterations.