Model can't find encoding_available variable [BUG]
See original GitHub issueDescribe the bug
After fitting TCN model, when attempting to backtest program spits out error regarding self.encoders.encoding_available
Error
AttributeError Traceback (most recent call last)
/tmp/ipykernel_1955/95313221.py in <module>
7 retrain=False,
8 num_samples=1,
----> 9 verbose=True,
10 )
/lib/python3.7/site-packages/darts/utils/utils.py in sanitized_method(self, *args, **kwargs)
170
171 getattr(self, sanity_check_method)(*only_args.values(), **only_kwargs)
--> 172 return method_to_sanitize(self, *only_args.values(), **only_kwargs)
173
174 return sanitized_method
/lib/python3.7/site-packages/darts/models/forecasting/forecasting_model.py in historical_forecasts(self, series, past_covariates, future_covariates, num_samples, start, forecast_horizon, stride, retrain, overlap_end, last_points_only, verbose)
421 past_covariates=past_covariates,
422 future_covariates=future_covariates,
--> 423 num_samples=num_samples,
424 )
425
/lib/python3.7/site-packages/darts/models/forecasting/forecasting_model.py in _predict_wrapper(self, n, series, past_covariates, future_covariates, num_samples)
1008 past_covariates=past_covariates,
1009 future_covariates=future_covariates,
-> 1010 num_samples=num_samples,
1011 )
1012
/lib/python3.7/site-packages/darts/utils/torch.py in decorator(self, *args, **kwargs)
68 with fork_rng():
69 manual_seed(self._random_instance.randint(0, high=MAX_TORCH_SEED_VALUE))
---> 70 return decorated(self, *args, **kwargs)
71
72 return decorator
/lib/python3.7/site-packages/darts/models/forecasting/torch_forecasting_model.py in predict(self, n, series, past_covariates, future_covariates, trainer, batch_size, verbose, n_jobs, roll_size, num_samples, num_loader_workers)
1076 )
1077
-> 1078 if self.encoders.encoding_available:
1079 past_covariates, future_covariates = self.encoders.encode_inference(
1080 n=n,
AttributeError: 'NoneType' object has no attribute 'encoding_available'
To Reproduce
backtest_series = model.historical_forecasts(
series_transformed,
start=series_transformed.get_timestamp_at_point(0.6),
forecast_horizon=7,
stride=5,
retrain=False,
num_samples=1,
verbose=True,
)
Expected behavior I expect to backtest on fitted model
System
- Python version: 3.7.11
- darts version 0.17.1
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Detect encoding and make everything UTF-8 - php
You first have to detect what encoding has been used. As you're parsing RSS feeds (probably via HTTP), you should read the encoding...
Read more >3 steps to fix encoding problems in Ruby - Justin Weiss
Most encodings are small, and can't handle every possible character. You'll see that error when a character in one encoding doesn't exist in...
Read more >Filename encoding errors · Issue #1368 · aws/aws-cli - GitHub
I'm using aws s3 sync to upload to a bucket, but I'm getting errors on many files: Please check your locale settings. The...
Read more >Charset issues - Apache FreeMarker Manual
You can use the encoding setting to specify the charset. This setting takes effect only when FreeMarker loads a template (parsed or unparsed)...
Read more >You should re-encode high cardinality categorical variables
Nina Zumel and I have been doing a lot of writing on the (important) details of re-encoding high cardinality categorical variables for ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Can you try
model = TCNModel.load_model('dt-model.pth.tar')
and see if this resolves the issue?load_model()
is a class method and returns the loaded model as a newTCNModel
object.Hey @Joe-TheBro, I tried your code snippet and it runs without issues…
This seems strange to me. The encoders should be initialized when
model.fit()
is called.Here are some questions:
print(darts.__version__)
model.fit()
failed and that your model is still in its initial state?print(model.epochs_trained)
and check if this is > 0?