Skip to content

Commit

Permalink
[python] Use double type for init_score array when set by predictor (
Browse files Browse the repository at this point in the history
  • Loading branch information
StrikerRUS authored Aug 27, 2021
1 parent c619931 commit 99cc4f2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions python-package/lightgbm/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1394,21 +1394,21 @@ def _set_init_score_by_predictor(self, predictor, data, used_indices=None):
if used_indices is not None:
assert not self.need_slice
if isinstance(data, (str, Path)):
sub_init_score = np.empty(num_data * predictor.num_class, dtype=np.float32)
sub_init_score = np.empty(num_data * predictor.num_class, dtype=np.float64)
assert num_data == len(used_indices)
for i in range(len(used_indices)):
for j in range(predictor.num_class):
sub_init_score[i * predictor.num_class + j] = init_score[used_indices[i] * predictor.num_class + j]
init_score = sub_init_score
if predictor.num_class > 1:
# need to regroup init_score
new_init_score = np.empty(init_score.size, dtype=np.float32)
new_init_score = np.empty(init_score.size, dtype=np.float64)
for i in range(num_data):
for j in range(predictor.num_class):
new_init_score[j * num_data + i] = init_score[i * predictor.num_class + j]
init_score = new_init_score
elif self.init_score is not None:
init_score = np.zeros(self.init_score.shape, dtype=np.float32)
init_score = np.zeros(self.init_score.shape, dtype=np.float64)
else:
return self
self.set_init_score(init_score)
Expand Down

0 comments on commit 99cc4f2

Please sign in to comment.