tweaks, try live trading

This commit is contained in:
Dobromir Popov
2025-07-08 01:33:22 +03:00
parent 9cd2d5d8a4
commit 4ab7bc1846
8 changed files with 141 additions and 201 deletions

View File

@ -5478,15 +5478,18 @@ class CleanTradingDashboard:
import torch
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
# Get the model's device to ensure tensors are on the same device
model_device = next(model.parameters()).device
# Handle different input shapes for different CNN models
if hasattr(model, 'input_shape'):
# EnhancedCNN model
features_tensor = torch.FloatTensor(features).unsqueeze(0).to(device)
features_tensor = torch.FloatTensor(features).unsqueeze(0).to(model_device)
else:
# Basic CNN model - reshape appropriately
features_tensor = torch.FloatTensor(features).unsqueeze(0).unsqueeze(0).to(device)
features_tensor = torch.FloatTensor(features).unsqueeze(0).unsqueeze(0).to(model_device)
target_tensor = torch.LongTensor([target]).to(device)
target_tensor = torch.LongTensor([target]).to(model_device)
# Set model to training mode and zero gradients
model.train()
@ -5605,10 +5608,11 @@ class CleanTradingDashboard:
if hasattr(network, 'forward'):
import torch
import torch.nn as nn
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
features_tensor = torch.FloatTensor(features).unsqueeze(0).to(device)
action_target_tensor = torch.LongTensor([action_target]).to(device)
confidence_target_tensor = torch.FloatTensor([confidence_target]).to(device)
# Get the model's device to ensure tensors are on the same device
model_device = next(network.parameters()).device
features_tensor = torch.FloatTensor(features).unsqueeze(0).to(model_device)
action_target_tensor = torch.LongTensor([action_target]).to(model_device)
confidence_target_tensor = torch.FloatTensor([confidence_target]).to(model_device)
network.train()
network_output = network(features_tensor)