Theob commited on
Commit
a1c0906
·
verified ·
1 Parent(s): 4901a7e

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +9 -0
handler.py CHANGED
@@ -121,6 +121,15 @@ class EndpointHandler:
121
  _, _, scenarios = self.tokenizer.decode(tokens)
122
  scenarios = scenarios[:, -steps:]
123
  print(f"Generated {n_scenarios} scenarios in {time.time() - t_start:.2f} seconds ⏱")
 
 
 
 
 
 
 
 
 
124
  return {
125
  "timestamps": (timestamps[-1] + torch.arange(1, steps+1) * torch.median(torch.diff(timestamps)).item()).tolist(),
126
  "open": scenarios[:, :, 0].tolist(),
 
121
  _, _, scenarios = self.tokenizer.decode(tokens)
122
  scenarios = scenarios[:, -steps:]
123
  print(f"Generated {n_scenarios} scenarios in {time.time() - t_start:.2f} seconds ⏱")
124
+ print("Nans:", torch.isnan(scenarios).sum().item())
125
+ print("Infs:", torch.isinf(scenarios).sum().item())
126
+ high_not_highest = (scenarios[..., :4].max(-1).values > scenarios[..., 1])
127
+ low_not_lowest = (scenarios[..., :4].min(-1).values < scenarios[..., 2])
128
+ invalid_candle = high_not_highest | low_not_lowest
129
+ print("Highest not high rate:", high_not_highest.float().mean().item())
130
+ print("Lowest not low rate:", low_not_lowest.float().mean().item())
131
+ print("Invalid candles rate:", invalid_candle.float().mean().item())
132
+ print("Invalid scenario rate:", invalid_candle.any(dim=-1).float().mean().item())
133
  return {
134
  "timestamps": (timestamps[-1] + torch.arange(1, steps+1) * torch.median(torch.diff(timestamps)).item()).tolist(),
135
  "open": scenarios[:, :, 0].tolist(),