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
Fix number of features mismatching in continual training (fix #5156) #5157
base: master
Are you sure you want to change the base?
Fix number of features mismatching in continual training (fix #5156) #5157
Changes from 5 commits
24b7df0
442c03a
2887ac0
0a20a13
bda5bdb
7e7190f
adb8982
c823137
750d35c
3e52538
23e9991
d719d78
aab8d1f
1f09936
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.
Hmmm, strange. With
3.3.2
version this test doesn't fail on my local machine each time. It fails sometimes.How about using not a random but concrete trivial dataset, something like
?
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.
Now a warning is provided, see https://github.com/microsoft/LightGBM/pull/5157/files#r868752144.
And the test case just checks whether the warning message is provided. Now it should always fail in
3.3.2
.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.
Isn't true for me 😕
I can sometimes successfully run the test on my Windows machine with LightGBM
3.3.2
installed from PyPI.Output:
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.
Sorry about that and thanks for checking.
I've updated the test case so that the initial model will surely use feature 8 or 9, and the continual training dataset contains only 5 features. Now the test case should always fail in previous versions.
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.
Thank you very much for working on the test!
However, now this test never fails (was run successfully 50 times in a row) on my machine with LightGBM
3.3.2
😄Log:
Model:
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.
@StrikerRUS
Did you test the test case in the latest commit of this PR?
I've tested with v3.3.2 with the test case
And the output is
which shows that the test case fails in v3.3.2.
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.
@shiyu1994 This test should segfault or something like this (I don't remember exactly) in
v3.3.2
but it doesn't.Warning was added after starting this review thread and we don't speak about it here.
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.
@StrikerRUS Thanks. With the latest commit, it should now fail in
v3.3.2
. It will segfaults or the AssertionError will arise by the linein the latest version of test case.
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.
Still doesn't fail in
v3.3.2
.Please use fixed dataset, not a random one, to constantly reproduce segfaults in versions without workaround from this PR.
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.
Why is it necessary to pass
predict_disable_shape_check
? This test isn't generating any predictions. Can this be removed?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.
Ah, good observation! But
predict()
is called internally here when you set init scores by a previously trained modelLightGBM/python-package/lightgbm/engine.py
Lines 153 to 154 in 0018206
LightGBM/python-package/lightgbm/engine.py
Lines 160 to 161 in 0018206
LightGBM/python-package/lightgbm/basic.py
Lines 1519 to 1522 in 0018206
LightGBM/python-package/lightgbm/basic.py
Line 1393 in 0018206
LightGBM/python-package/lightgbm/basic.py
Lines 1399 to 1402 in 0018206
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.
Ah, I see! So then is the bug addressed by this PR only present when you've also set
predict_disable_shape_check = True
? I expect that most LightGBM users will not be aware that that prediction parameter is relevant for training continuation.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.
Yes, without setting
predict_disable_shape_check = True
users get the following error:I think the second sentence of the error "You can set
predict_disable_shape_check=true
to discard this error ..." helps understand this complicated relationship.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.
predict_disable_shape_check
is necessary because here a numpy matrix is used in the test case. If we use a LibSVM file as dataset in the test case, we don't needpredict_disable_shape_check=True
. I use a numpy matrix here because I think it is more convenient than LivSVM in that it does not requiring generating files in test cases.