From 8354aec83025f82f038c95e80327fff2a16affe4 Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Wed, 12 Nov 2025 18:11:19 +0200 Subject: [PATCH] fixed model training --- ANNOTATE/core/real_training_adapter.py | 6 +++--- ANNOTATE/web/app.py | 2 +- NN/models/advanced_transformer_trading.py | 2 +- NN/models/cob_rl_model.py | 2 +- NN/models/dqn_agent.py | 2 +- core/realtime_rl_cob_trader.py | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ANNOTATE/core/real_training_adapter.py b/ANNOTATE/core/real_training_adapter.py index d9f1e52..6d883aa 100644 --- a/ANNOTATE/core/real_training_adapter.py +++ b/ANNOTATE/core/real_training_adapter.py @@ -815,8 +815,8 @@ class RealTrainingAdapter: continue if entry_index is None: - logger.warning(f"Could not find entry timestamp in market data") - return negative_samples + logger.debug(f"Could not find entry timestamp in market data - using first candle as entry") + entry_index = 0 # Use first candle if exact match not found # If exit not found, estimate it if exit_index is None: @@ -1958,7 +1958,7 @@ class RealTrainingAdapter: 'training_id': session.training_id }, file_path=checkpoint_path, - performance_score=float(avg_accuracy), # Use accuracy as score + file_size_mb=os.path.getsize(checkpoint_path) / (1024 * 1024) if os.path.exists(checkpoint_path) else 0.0, is_active=True ) diff --git a/ANNOTATE/web/app.py b/ANNOTATE/web/app.py index 2f54c91..41a4d65 100644 --- a/ANNOTATE/web/app.py +++ b/ANNOTATE/web/app.py @@ -213,7 +213,7 @@ class AnnotationDashboard: SELECT checkpoint_id, performance_metrics, timestamp, file_path FROM checkpoint_metadata WHERE model_name = ? AND is_active = TRUE - ORDER BY performance_score DESC + ORDER BY timestamp DESC LIMIT 1 """, (model_name.lower(),)) diff --git a/NN/models/advanced_transformer_trading.py b/NN/models/advanced_transformer_trading.py index 0d8684e..402888b 100644 --- a/NN/models/advanced_transformer_trading.py +++ b/NN/models/advanced_transformer_trading.py @@ -1229,7 +1229,7 @@ class TradingTransformerTrainer: for k, v in batch.items()} # Use automatic mixed precision (FP16) for memory efficiency - with torch.cuda.amp.autocast(enabled=self.use_amp): + with torch.amp.autocast('cuda', enabled=self.use_amp): # Forward pass with multi-timeframe data outputs = self.model( price_data_1s=batch.get('price_data_1s'), diff --git a/NN/models/cob_rl_model.py b/NN/models/cob_rl_model.py index 4ffbba1..6abaf11 100644 --- a/NN/models/cob_rl_model.py +++ b/NN/models/cob_rl_model.py @@ -323,7 +323,7 @@ class COBRLModelInterface(ModelInterface): self.optimizer.zero_grad() if self.scaler: - with torch.cuda.amp.autocast(): + with torch.amp.autocast('cuda'): outputs = self.model(features) loss = self._calculate_loss(outputs, targets) diff --git a/NN/models/dqn_agent.py b/NN/models/dqn_agent.py index 06700f7..84d4678 100644 --- a/NN/models/dqn_agent.py +++ b/NN/models/dqn_agent.py @@ -1436,7 +1436,7 @@ class DQNAgent: import warnings with warnings.catch_warnings(): warnings.simplefilter("ignore", FutureWarning) - with torch.cuda.amp.autocast(): + with torch.amp.autocast('cuda'): # Get current Q values and predictions current_q_values, current_extrema_pred, current_price_pred, hidden_features, current_advanced_pred = self._safe_cnn_forward(self.policy_net, states) current_q_values = current_q_values.gather(1, actions.unsqueeze(1)).squeeze(1) diff --git a/core/realtime_rl_cob_trader.py b/core/realtime_rl_cob_trader.py index 4269820..8715051 100644 --- a/core/realtime_rl_cob_trader.py +++ b/core/realtime_rl_cob_trader.py @@ -536,7 +536,7 @@ class RealtimeRLCOBTrader: features_tensor = torch.from_numpy(features).unsqueeze(0).to(self.device) with torch.no_grad(): - with torch.cuda.amp.autocast(): + with torch.amp.autocast('cuda'): outputs = model(features_tensor) # Extract predictions @@ -934,7 +934,7 @@ class RealtimeRLCOBTrader: ], dtype=torch.float32).to(self.device) # Forward pass with mixed precision - with torch.cuda.amp.autocast(): + with torch.amp.autocast('cuda'): outputs = model(features) # Calculate losses