错误:add_nan=True在 pytorch 预测中创建时间序列数据集时,“遇到未知类别 '2'。设置为允许未知类别”。
training = TimeSeriesDataSet(
train,
time_idx="index",
target=dni,
group_ids=["Solar Zenith Angle", "Relative Humidity","Dew
Point","Temperature","Precipitable Water", "Wind Speed"],
min_encoder_length=max_encoder_length // 2, # keep encoder length long (as it is in the
validation set)
max_encoder_length=max_encoder_length,
min_prediction_length=1,
max_prediction_length=max_prediction_length,
static_reals=["Wind Direction"],
time_varying_known_reals=["index", "Solar Zenith Angle", "Relative Humidity","Dew
Point","Temperature","Precipitable Water"],
# time_varying_unknown_categoricals=[],
time_varying_unknown_reals=[dhi,dni,ghi],
categorical_encoders={data.columns[2]: NaNLabelEncoder(add_nan=True)},
target_normalizer=GroupNormalizer(
groups=["Solar Zenith Angle", "Relative Humidity","Dew
Point","Temperature","Precipitable Water", "Wind Speed"], transformation="softplus"
), # use softplus and normalize by group
add_relative_time_idx=True,
add_target_scales=True,
add_encoder_length=True,
Run Code Online (Sandbox Code Playgroud)
)
我试图从 pytorch_forecasting 模块进行时间融合变压器,但我在 trainer.fit 方法中遇到错误:model必须是 aLightningModule或torch._dynamo.OptimizedModule,得到TemporalFusionTransformer。我只是从“towardsdatascience”复制这篇论文。参考: https: //towardsdatascience.com/temporal -fusion-transformer-time-series-forecasting-with-deep-learning-complete-tutorial-d32c1e51cd91#:~:text=T%20emporal%20F%20usion%20T,dynamics%20of%20multiple%20time%20sequences。