Open stellaywu opened 3 years ago
figured out it should be train_model.trained_net.save_parameters(file_name)
sorry still need help, not sure how to load the saved params back to estimator in inference. If I save the model with the following code will get a non-serializable error.
estimator = DeepStateEstimator(
prediction_length=prediction_length,
freq=freq,
past_length = context_length,
cardinality = [1],
use_feat_static_cat = False,
trainer=Trainer
(
learning_rate=1e-3,
epochs=50,
num_batches_per_epoch=100,
ctx = ctx
),
)
predictor= estimator.train_model(train_ds)
from pathlib import Path
estimator.serialize(Path(file_name))
will raise error AttributeError: 'DeepStateEstimator' object has no attribute 'serialize'
Hi @stellaywu,
do you really want to save the estimator
? If your goal is to save a model to do inference later, you actually want to serialize the predictor
, like this.
thanks for the reply @mbohlkeschneider I got this error when serialize because I am using estimator.train_model instead of estimator.train as I wanted to get the distribution which only exist in train_model. Any idea how to bypass that?
AttributeError Traceback (most recent call last)
<ipython-input-17-79a7c4bc6053> in <module>()
3
4 from pathlib import Path
----> 5 predictor_deepar.serialize(Path(file_name))
AttributeError: 'TrainOutput' object has no attribute 'serialize'
Thanks!
Maybe you could initialize weights by
estimator = DeepStateEstimator(
prediction_length=prediction_length,
freq=freq,
past_length = context_length,
cardinality = [1],
use_feat_static_cat = False,
trainer=Trainer
(
learning_rate=1e-3,
epochs=50,
num_batches_per_epoch=100,
ctx = ctx
init=init.Load(file_name)
),
)
Trainer
has a initialization way of init
Hi, I'm trying to save an estimator trained from the train_model function, tried
.save_parameters(file_name)
and.serialize(Path(file_name))
, gotAttributeError: 'DeepAREstimator' object has no attribute 'serialize'
Please help.
Thanks