Skip to content
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: restore overwrite of eval_batch_size on GBM schema #2345

Merged
merged 5 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion ludwig/schema/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from marshmallow_dataclass import dataclass

from ludwig.constants import COMBINED, LOSS, MODEL_ECD, MODEL_GBM, TRAINING, TYPE
from ludwig.constants import AUTO, COMBINED, LOSS, MODEL_ECD, MODEL_GBM, TRAINING, TYPE
from ludwig.schema import utils as schema_utils
from ludwig.schema.metadata.trainer_metadata import TRAINER_METADATA
from ludwig.schema.optimizers import (
Expand Down Expand Up @@ -312,6 +312,19 @@ class GBMTrainerConfig(BaseTrainerConfig):
allow_none=False,
)

# NOTE: Overwritten here to provide a default value. In many places, we fall back to eval_batch_size if batch_size
# is not specified. GBM does not have a value for batch_size, so we need to specify eval_batch_size here.
eval_batch_size: Union[None, int, str] = schema_utils.IntegerOrAutoField(
default=AUTO,
allow_none=False,
min_exclusive=0,
description=(
"Size of batch to pass to the model for evaluation. "
"Defaults to 'auto': the biggest batch size (power of 2) that can fit in memory will be used."
),
parameter_metadata=TRAINER_METADATA["eval_batch_size"],
)

# LightGBM core parameters (https://lightgbm.readthedocs.io/en/latest/Parameters.html)
boosting_type: str = schema_utils.StringOptions(
["gbdt", "rf", "dart", "goss"],
Expand Down
2 changes: 1 addition & 1 deletion ludwig/trainers/trainer_lightgbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(
self.skip_save_progress = skip_save_progress
self.skip_save_model = skip_save_model

self.eval_batch_size = config.eval_batch_size or 128
self.eval_batch_size = config.eval_batch_size
self._validation_field = config.validation_field
self._validation_metric = config.validation_metric
self.evaluate_training_set = config.evaluate_training_set
Expand Down