Spaces:
Paused
Paused
Tonic commited on
Commit ·
6616ba7
1
Parent(s): cf7c042
solve d-type handling error
Browse files
app.py
CHANGED
|
@@ -319,12 +319,14 @@ def make_prediction(symbol: str, timeframe: str = "1d", prediction_days: int = 5
|
|
| 319 |
# Make prediction with GPU acceleration
|
| 320 |
pipe = load_pipeline()
|
| 321 |
|
| 322 |
-
# Get the model's device
|
| 323 |
device = next(pipe.model.parameters()).device
|
|
|
|
| 324 |
print(f"Model device: {device}")
|
|
|
|
| 325 |
|
| 326 |
# Convert to tensor and ensure proper shape and device
|
| 327 |
-
context = torch.tensor(normalized_prices, dtype=
|
| 328 |
|
| 329 |
# Adjust prediction length based on timeframe
|
| 330 |
if timeframe == "1d":
|
|
@@ -354,9 +356,15 @@ def make_prediction(symbol: str, timeframe: str = "1d", prediction_days: int = 5
|
|
| 354 |
if len(context.shape) == 1:
|
| 355 |
context = context.unsqueeze(0) # Add batch dimension
|
| 356 |
|
| 357 |
-
# Verify device
|
| 358 |
print(f"Context device: {context.device}")
|
|
|
|
| 359 |
print(f"Model device: {next(pipe.model.parameters()).device}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 360 |
|
| 361 |
# Use predict_quantiles with proper formatting
|
| 362 |
quantiles, mean = pipe.predict_quantiles(
|
|
|
|
| 319 |
# Make prediction with GPU acceleration
|
| 320 |
pipe = load_pipeline()
|
| 321 |
|
| 322 |
+
# Get the model's device and dtype
|
| 323 |
device = next(pipe.model.parameters()).device
|
| 324 |
+
dtype = next(pipe.model.parameters()).dtype
|
| 325 |
print(f"Model device: {device}")
|
| 326 |
+
print(f"Model dtype: {dtype}")
|
| 327 |
|
| 328 |
# Convert to tensor and ensure proper shape and device
|
| 329 |
+
context = torch.tensor(normalized_prices, dtype=dtype, device=device)
|
| 330 |
|
| 331 |
# Adjust prediction length based on timeframe
|
| 332 |
if timeframe == "1d":
|
|
|
|
| 356 |
if len(context.shape) == 1:
|
| 357 |
context = context.unsqueeze(0) # Add batch dimension
|
| 358 |
|
| 359 |
+
# Verify device and dtype
|
| 360 |
print(f"Context device: {context.device}")
|
| 361 |
+
print(f"Context dtype: {context.dtype}")
|
| 362 |
print(f"Model device: {next(pipe.model.parameters()).device}")
|
| 363 |
+
print(f"Model dtype: {next(pipe.model.parameters()).dtype}")
|
| 364 |
+
|
| 365 |
+
# Move model to evaluation mode and ensure it's on the correct device
|
| 366 |
+
pipe.model.eval()
|
| 367 |
+
pipe.model = pipe.model.to(device)
|
| 368 |
|
| 369 |
# Use predict_quantiles with proper formatting
|
| 370 |
quantiles, mean = pipe.predict_quantiles(
|