integrating new CNN model

This commit is contained in:
Dobromir Popov
2025-07-23 16:59:35 +03:00
parent 1be270cc5c
commit f1d63f9da6
15 changed files with 1896 additions and 1003 deletions

View File

@ -11,11 +11,17 @@ This package contains the neural network models used in the trading system:
PyTorch implementation only.
"""
from NN.models.cnn_model import EnhancedCNNModel as CNNModel
from NN.models.dqn_agent import DQNAgent
from NN.models.cob_rl_model import MassiveRLNetwork, COBRLModelInterface
# Import core models
from NN.models.dqn_agent import DQNAgent, MassiveRLNetwork
from NN.models.cob_rl_model import COBRLModelInterface
from NN.models.advanced_transformer_trading import AdvancedTradingTransformer, TradingTransformerConfig
from NN.models.standardized_cnn import StandardizedCNN # Use the unified CNN model
# Import model interfaces
from NN.models.model_interfaces import ModelInterface, CNNModelInterface, RLAgentInterface, ExtremaTrainerInterface
__all__ = ['CNNModel', 'DQNAgent', 'MassiveRLNetwork', 'COBRLModelInterface', 'AdvancedTradingTransformer', 'TradingTransformerConfig',
'ModelInterface', 'CNNModelInterface', 'RLAgentInterface', 'ExtremaTrainerInterface']
# Export the unified StandardizedCNN as CNNModel for compatibility
CNNModel = StandardizedCNN
__all__ = ['CNNModel', 'StandardizedCNN', 'DQNAgent', 'MassiveRLNetwork', 'COBRLModelInterface', 'AdvancedTradingTransformer', 'TradingTransformerConfig',
'ModelInterface', 'CNNModelInterface', 'RLAgentInterface', 'ExtremaTrainerInterface']

File diff suppressed because it is too large Load Diff

View File

@ -371,6 +371,10 @@ class EnhancedCNN(nn.Module):
nn.Linear(128, 4) # Low risk, medium risk, high risk, extreme risk
)
def _memory_barrier(self, tensor: torch.Tensor) -> torch.Tensor:
"""Create a memory barrier to prevent in-place operation issues"""
return tensor.detach().clone().requires_grad_(tensor.requires_grad)
def _check_rebuild_network(self, features):
"""Check if network needs to be rebuilt for different feature dimensions"""
# Prevent rebuilding with zero or invalid dimensions