tweaks, try live trading
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user