Update README.md
Browse files
README.md
CHANGED
|
@@ -26,11 +26,13 @@ model = AutoModelForCausalLM.from_pretrained('thuml/timer-base', trust_remote_co
|
|
| 26 |
|
| 27 |
# prepare input
|
| 28 |
batch_size, lookback_length = 1, 2880
|
| 29 |
-
seqs = torch.randn(batch_size, lookback_length)
|
| 30 |
-
|
|
|
|
|
|
|
| 31 |
normed_seqs = (seqs - mean) / std
|
| 32 |
|
| 33 |
-
# forecast
|
| 34 |
prediction_length = 96
|
| 35 |
normed_output = model.generate(normed_seqs, max_new_tokens=prediction_length)[:, -prediction_length:]
|
| 36 |
output = std * normed_output + mean # rescale the output to the original scale
|
|
|
|
| 26 |
|
| 27 |
# prepare input
|
| 28 |
batch_size, lookback_length = 1, 2880
|
| 29 |
+
seqs = torch.randn(batch_size, lookback_length)
|
| 30 |
+
|
| 31 |
+
# normalize the input to mitigate different scale
|
| 32 |
+
mean, std = seqs.mean(dim=-1, keepdim=True), seqs.std(dim=-1, keepdim=True)
|
| 33 |
normed_seqs = (seqs - mean) / std
|
| 34 |
|
| 35 |
+
# generate forecast
|
| 36 |
prediction_length = 96
|
| 37 |
normed_output = model.generate(normed_seqs, max_new_tokens=prediction_length)[:, -prediction_length:]
|
| 38 |
output = std * normed_output + mean # rescale the output to the original scale
|