fix: 缺PyTorch时训练不会因ImportError中断整个流程
This commit is contained in:
parent
b6b072d844
commit
531cff509d
@ -500,12 +500,16 @@ class ModelTrainer:
|
||||
model.fit(X_train, y_train)
|
||||
|
||||
elif model_type == 'pytorch':
|
||||
# 训练PyTorch模型
|
||||
# 训练PyTorch模型(如未安装则跳过)
|
||||
try:
|
||||
train_dataset = EquipmentDataset(X_train, y_train)
|
||||
train_loader = DataLoader(train_dataset, batch_size=32, shuffle=True)
|
||||
training_success = self.train_model(train_loader)
|
||||
if not training_success:
|
||||
continue
|
||||
except ImportError as e:
|
||||
logger.warning(f"PyTorch not available, skipping: {e}")
|
||||
continue
|
||||
|
||||
# 评估模型性能
|
||||
if model_type == 'pytorch':
|
||||
|
||||
Loading…
Reference in New Issue
Block a user