fix: 修复部分已知问题

This commit is contained in:
2026-03-30 21:42:00 +08:00
parent 3e33c14376
commit 0e7fc623b4
10 changed files with 254 additions and 43 deletions
+3 -6
View File
@@ -74,19 +74,16 @@ class SchedulerCallback(TrainCallback):
Scheduler callback for trainer.
"""
def __init__(self):
self.scheduler: LRScheduler = None
pass
def on_train_begin(self, context: TrainContext):
for group in context.optimizer.param_groups:
if "initial_lr" not in group:
group["initial_lr"] = group["lr"]
self.scheduler = context.scheduler
def on_batch_end(self, context: TrainContext):
_ = context
if self.scheduler:
self.scheduler.step()
if context.scheduler:
context.scheduler.step()
class CheckpointCallback(TrainCallback):
+1 -1
View File
@@ -87,7 +87,7 @@ class TrainContextBuilder:
return self
def with_strategy(self) -> Self:
self._context.strategy = StrategyFactory.load(
self._context.strategy = StrategyFactory.create(
model=self._context.model,
train_type=self.config.strategy,
device=get_current_device(),