Closed Carkham closed 2 years ago
@Carkham thanks for filing the issue! I'm able to reproduce it on dev
as well, we'll have to look into this.
Following is a simpler reproducer. What's interesting is that skipping the as_symbol_block_predictor
and doing predictor.serialize
directly appears to be running fine.
from gluonts.dataset.repository.datasets import get_dataset
from gluonts.mx.model.simple_feedforward import SimpleFeedForwardEstimator
from gluonts.mx.trainer import Trainer
from gluonts.mx.model.predictor import Predictor
from pathlib import Path
model_path = Path(__file__).parent / "model"
dataset = get_dataset("m4_hourly")
estimator = SimpleFeedForwardEstimator(
prediction_length=dataset.metadata.prediction_length,
trainer=Trainer(
epochs=2,
num_batches_per_epoch=5,
),
)
predictor = estimator.train(dataset.train)
predictor = predictor.as_symbol_block_predictor(dataset=dataset.train)
model_path.mkdir()
predictor.serialize(model_path)
new_symbol_predictor = Predictor.deserialize(model_path)
forecasts = list(new_symbol_predictor.predict(dataset.train))
Other observations:
SimpleFeedForwardEstimator
mxnet==1.9.1
mxnet==1.7.0.post2
mxnet==1.8.0.post0
, see following stack traceTraceback (most recent call last):
File "issues/2180/run.py", line 36, in <module>
predictor.as_symbol_block_predictor(dataset=dataset.train).serialize(model_path)
File "/Users/stellalo/gluon-ts/src/gluonts/mx/model/predictor.py", line 189, in serialize
self.serialize_prediction_net(path)
File "/Users/stellalo/gluon-ts/src/gluonts/mx/model/predictor.py", line 234, in serialize_prediction_net
export_symb_block(self.prediction_net, path, "prediction_net")
File "/Users/stellalo/gluon-ts/src/gluonts/mx/util.py", line 207, in export_symb_block
hb.export(path=str(model_dir / model_name), epoch=epoch)
File "/Users/stellalo/.virtualenvs/gluonts/lib/python3.7/site-packages/mxnet/gluon/block.py", line 1284, in export
for is_arg, param in self._cached_op_args:
AttributeError: 'SymbolBlock' object has no attribute '_cached_op_args'
Size of the prediction_net-0000.params
file, resulting from serializing the model in my snippet above:
as_symbol_block_predictor
: 316KB
as_symbol_block_predictor
: 32B
So some stuff is missing there.
Description
Hello, I tried to serialize my predictor as symbo block format, but when I deserialize them and use for predition, I got some error show below
To Reproduce
Error message or code output
Environment
(Add as much information about your environment as possible, e.g. dependencies versions.)