fixed other CNN references
This commit is contained in:
@ -431,11 +431,11 @@ class EnhancedCNNModel(nn.Module):
|
||||
return {
|
||||
'action': action,
|
||||
'action_name': 'BUY' if action == 0 else 'SELL',
|
||||
'confidence': float(confidence),
|
||||
'confidence': confidence, # Already converted to float above
|
||||
'action_confidence': action_confidence,
|
||||
'probabilities': probs.tolist(),
|
||||
'regime_probabilities': regime.tolist(),
|
||||
'volatility_prediction': float(volatility),
|
||||
'volatility_prediction': volatility, # Already converted to float above
|
||||
'raw_logits': outputs['logits'].cpu().numpy()[0].tolist()
|
||||
}
|
||||
|
||||
|
@ -501,7 +501,16 @@ class EnhancedCNNWithOrderBook(nn.Module):
|
||||
# Get probabilities
|
||||
q_values = outputs['q_values']
|
||||
probs = F.softmax(q_values, dim=1)
|
||||
confidence = outputs['confidence'].item()
|
||||
|
||||
# Handle confidence shape properly to avoid scalar conversion errors
|
||||
confidence_tensor = outputs['confidence']
|
||||
if isinstance(confidence_tensor, torch.Tensor):
|
||||
if confidence_tensor.numel() == 1:
|
||||
confidence = confidence_tensor.item()
|
||||
else:
|
||||
confidence = confidence_tensor.flatten()[0].item()
|
||||
else:
|
||||
confidence = float(confidence_tensor)
|
||||
|
||||
# Action selection with confidence thresholding
|
||||
if confidence >= self.confidence_threshold:
|
||||
|
Reference in New Issue
Block a user