better error msgs

This commit is contained in:
Dobromir Popov
2025-12-08 17:15:31 +02:00
parent 03888b6200
commit 8263534b74
2 changed files with 22 additions and 4 deletions

View File

@@ -525,9 +525,22 @@ class AdvancedTradingTransformer(nn.Module):
# Filter to available timeframes
available_tfs = [(tf, data) for tf, data in timeframe_data.items() if data is not None]
if not available_tfs:
raise ValueError("At least one timeframe must be provided")
# Handle case where no timeframes are available (e.g., missing training data)
# Return a default output that won't break training
logger.warning("No timeframe data available for transformer forward pass")
batch_size = 1 # Default batch size
device = torch.device('cpu') # Default to CPU when no data available
# Return default outputs with appropriate shapes
return {
'action_logits': torch.zeros(batch_size, 3, device=device), # 3 actions: HOLD, BUY, SELL
'trend_logits': torch.zeros(batch_size, 3, device=device), # 3 trends: DOWN, SIDEWAYS, UP
'candle_logits': torch.zeros(batch_size, 2, device=device), # 2 candle types: NORMAL, EXTREMA
'price_prediction': torch.zeros(batch_size, 1, device=device),
'confidence': torch.zeros(batch_size, 1, device=device),
'attention_weights': None
}
# Get dimensions from first available timeframe
first_data = available_tfs[0][1]