基本模型#
- class pytorch_forecasting.models.base_model.BaseModel(dataset_parameters: Dict[str, Any] = None, log_interval: int | float = -1, log_val_interval: int | float = None, learning_rate: float | List[float] = 0.001, log_gradient_flow: bool = False, loss: 指标 = SMAPE(), logging_metrics: ModuleList = ModuleList(), reduce_on_plateau_patience: int = 1000, reduce_on_plateau_reduction: float = 2.0, reduce_on_plateau_min_lr: float = 1e-05, weight_decay: float = 0.0, optimizer_params: Dict[str, Any] = None, monotone_constraints: Dict[str, int] = {}, output_transformer: Callable = None, optimizer='adam')[来源]#
基类:
InitialParameterRepresenterMixIn
,LightningModule
,TupleOutputMixIn
新时间序列模型应该继承的基模型。创建的对象的
hparams
将默认为__init__()
中指示的参数。该
forward()
方法应该返回一个包含至少条目prediction
的命名元组,该条目包含网络的输出。有关更多详细信息,请参见该函数的文档。基础模型的想法是常见方法不必为每个新架构重新实现。 该类是一个 [LightningModule](https://pytorch-lightning.readthedocs.io/en/latest/lightning_module.html) 并遵循其规范。然而,还有一些重要的补充:
您需要指定一个
loss
属性,用于存储计算反向传播的MultiHorizonLoss
的函数。可以使用
from_dataset()
方法根据数据集的规格初始化网络。通常,像特征数量这样的参数可以很容易地从数据集中推断出来。此外,该方法还会存储如何将规范化预测重新缩放到未规范化的预测空间。重写它以将额外的参数传递给依赖于您的数据集的网络__init__方法。该
transform_output()
方法使用数据集中的目标归一化器对网络输出进行重新缩放。step()
方法负责计算损失,记录在logging_metrics
属性中定义的额外度量,并绘制样本预测图。您可以重写此方法以添加自定义解释或将额外参数传递给网络的前向方法。on_epoch_end()
方法可用于计算每个纪元的摘要,例如编码器长度的统计信息等,并需要返回输出。这个
predict()
方法使用数据加载器或数据集进行预测。如果您需要默认情况下将额外参数传递给forward
,请重写它。
为了实现您自己的架构,最好查看使用自定义数据和实现自定义模型,并查看现有的架构以了解什么可能是一个好的方法。
示例
class Network(BaseModel): def __init__(self, my_first_parameter: int=2, loss=SMAPE()): self.save_hyperparameters() super().__init__(loss=loss) def forward(self, x): normalized_prediction = self.module(x) prediction = self.transform_output(prediction=normalized_prediction, target_scale=x["target_scale"]) return self.to_network_output(prediction=prediction)
用于继承的时间序列预测的基础模型
- Parameters:
log_interval (Union[int, float], optional) – 预测将被记录的批次数。如果 < 1.0,则每个批次会记录多个条目。默认值为 -1。
log_val_interval (Union[int, float], optional) – 预测验证结果记录的批次数。默认为 None/log_interval。
learning_rate (float, 可选) – 学习率。默认为 1e-3。
log_gradient_flow (bool) – 如果要记录梯度流,这会耗费时间,应仅用于诊断训练失败。默认为 False。
损失 (指标, 可选) – 要优化的指标,也可以是指标的列表。默认为 SMAPE()。
logging_metrics (nn.ModuleList[MultiHorizonMetric]) – 在训练期间记录的度量列表。默认为[]。
reduce_on_plateau_patience (int) – 在此之后学习率减少10倍的耐心。默认为1000
reduce_on_plateau_reduction (float) – 当遇到平台期时,学习率的减少。默认值为 2.0。
reduce_on_plateau_min_lr (float) – 降至平台学习率调度器的最小学习率。默认值为 1e-5
weight_decay (float) – 权重衰减。默认为 0.0。
optimizer_params (字典[字符串, 任意类型]) – 优化器的附加参数。默认为 {}.
monotone_constraints (Dict[str, int]) – 用于连续解码器变量的单调性约束字典 将位置映射到约束(例如,
"0"
表示第一个位置)(-1
表示负约束,+1
表示正约束, 较大的数字对约束相对于损失增加更多的权重,但通常是不必要的)。 这个约束显著减慢训练速度。默认值为 {}。output_transformer (可调用对象) – 转换器,将网络输出转换为预测空间。默认为 None,相当于
lambda out: out["prediction"]
。optimizer (str) – 优化器,“ranger”、“sgd”、“adam”、“adamw”或
torch.optim
中的优化器类名或pytorch_optimizer
。可以传递一个类或函数,该类或函数将参数作为第一个参数,并可选地带有lr参数(也可以有weight_decay)。默认为“adam”。
方法
配置优化器。
create_log
(x, y, out, batch_idx[, ...])创建在训练和验证步骤中使用的日志。
deduce_default_output_parameters
(dataset, kwargs)推导
from_dataset()
方法的默认输出参数。forward
(x)网络前向传播。
from_dataset
(数据集, **kwargs)从数据集中创建模型,即将数据集参数保存在模型中。
log
(*args, **kwargs)参见
lightning.pytorch.core.lightning.LightningModule.log()
。log_gradient_flow
(named_parameters)梯度的对数分布以识别梯度爆炸/消失
log_metrics
(x, y, out[, prediction_kwargs])每个训练/验证步骤记录日志指标。
log_prediction
(x, out, batch_idx, **kwargs)在每个训练/验证步骤记录日志指标。
用于调试的日志梯度流。
on_epoch_end
(outputs)在训练或验证的周期结束时运行。
on_load_checkpoint
(checkpoint)由Lightning调用以恢复您的模型。
on_save_checkpoint
(checkpoint)在保存检查点时由Lightning调用,以便给您机会存储您可能想要保存的其他内容。
在时序的最后阶段被调用。
在周期结束时在训练循环中调用。
在每个周期结束时的验证循环中被调用。
plot_prediction
(x, out[, idx, ...])绘制预测值与实际值的对比图
predict
(数据[, 模式, 返回索引, ...])运行推理 / 预测。
predict_dependency
(data, variable, values[, ...])预测部分依赖。
predict_step
(批量, 批量索引)在
predict()
期间调用的阶跃函数。size
()获取模型中的参数数量
step
(x, y, batch_idx, **kwargs)针对每个训练/验证步骤运行。
test_step
(批量,批量索引)在测试集的单个数据批次上操作。
to_prediction
(out[, use_metric])使用损失指标将输出转换为预测。
to_quantiles
(out[, use_metric])使用损失指标将输出转换为分位数。
training_step
(batch, batch_idx)在批量上训练。
transform_output
(预测, 目标尺度[, ...])从网络输出中提取预测并将其重新缩放到真实空间/去规范化它。
validation_step
(batch, batch_idx)对来自验证集的单个数据批次进行操作。
- configure_optimizers()[来源]#
配置优化器。
使用单个 Ranger 优化器。根据学习率是列表还是单个浮点数,来实现动态学习率调度器或确定性版本
- Returns:
第一个条目是优化器的列表,第二个是调度器的列表
- Return type:
元组[列表]
- create_log(x: Dict[str, Tensor], y: Tuple[Tensor, Tensor], out: Dict[str, Tensor], batch_idx: int, prediction_kwargs: Dict[str, Any] | None = None, quantiles_kwargs: Dict[str, Any] | None = None) Dict[str, Any] [来源]#
创建在训练和验证步骤中使用的日志。
- Parameters:
x (字典[字符串, torch.Tensor]) – 通过数据加载器传递给网络的 x
y (Tuple[torch.Tensor, torch.Tensor]) – 作为由数据加载器传递给损失函数的 y
out (字典[字符串, torch.Tensor]) – 网络的输出
batch_idx (int) – 批次编号
prediction_kwargs (字典[字符串, 任意类型], 可选) – 传递给
to_prediction()
的参数。默认为 {}。quantiles_kwargs (字典[字符串, 任何类型], 可选) –
to_quantiles()
. 默认值为 {}.
- Returns:
训练和验证步骤返回的日志字典
- Return type:
字典[str, 任何]
- static deduce_default_output_parameters(dataset: 时间序列数据集, kwargs: Dict[str, Any], default_loss: 多视角指标 = None) Dict[str, Any] [来源]#
推导
from_dataset()
方法的默认输出参数。确定
output_size
和loss
参数。- Parameters:
dataset (TimeSeriesDataSet) – 时间序列数据集
kwargs (字典[字符串, 任何]) – 当前超参数
default_loss (MultiHorizonMetric, 可选) – 默认损失函数。默认为
MAE
。
- Returns:
包含
output_size
和loss
的字典。- Return type:
字典[str, 任何]
- forward(x: Dict[str, List[Tensor] | Tensor]) Dict[str, List[Tensor] | Tensor] [来源]#
网络前向传播。
- Parameters:
x (字典[字符串, 联合[torch.Tensor, 列表[torch.Tensor]]]) – 网络输入 (由数据加载器返回的 x)。 查看
to_dataloader()
方法,该方法返回x
和y
的元组。此函数期望x
。- Returns:
- 网络输出 / 张量字典或列表
张量。使用
to_network_output()
方法创建它。 字典中最小所需的条目是(括号中的形状):prediction
(batch_size x n_decoder_time_steps x n_outputs或每个条目对应于不同目标的列表):可以输入到指标中的重新缩放的预测。如果同时预测多个目标,则为张量列表。
在输出预测之前,您希望将它们重新缩放到实际空间。 默认情况下,您可以使用
transform_output()
方法来实现这一点。
- Return type:
命名元组[联合[torch.Tensor, 列表[torch.Tensor]]]
示例
def forward(self, x: # x is a batch generated based on the TimeSeriesDataset, here we just use the # continuous variables for the encoder network_input = x["encoder_cont"].squeeze(-1) prediction = self.linear(network_input) # # rescale predictions into target space prediction = self.transform_output(prediction, target_scale=x["target_scale"]) # We need to return a dictionary that at least contains the prediction # The parameter can be directly forwarded from the input. # The conversion to a named tuple can be directly achieved with the `to_network_output` function. return self.to_network_output(prediction=prediction)
- classmethod from_dataset(dataset: 时间序列数据集, **kwargs) LightningModule [来源]#
从数据集中创建模型,即将数据集参数保存在模型中
这个函数应该在实现它的派生模型中被调用为
super().from_dataset()
- Parameters:
dataset (TimeSeriesDataSet) – 时间序列数据集
- Returns:
可以训练的模型
- Return type:
- log_metrics(x: Dict[str, Tensor], y: Tensor, out: Dict[str, Tensor], prediction_kwargs: Dict[str, Any] = None) None [来源]#
在每个训练/验证步骤记录日志指标。
- Parameters:
x (字典[字符串, torch.Tensor]) – 通过数据加载器传递给网络的 x
y (torch.Tensor) – 数据加载器将 y 传递给损失函数
out (字典[字符串, torch.Tensor]) – 网络的输出
prediction_kwargs (Dict[str, Any]) – 用于
to_prediction()
的损失指标的参数。
- log_prediction(x: Dict[str, Tensor], out: Dict[str, Tensor], batch_idx: int, **kwargs) None [来源]#
在每个训练/验证步骤记录日志指标。
- Parameters:
x (字典[字符串, torch.Tensor]) – 通过数据加载器传递给网络的 x
out (字典[字符串, torch.Tensor]) – 网络的输出
batch_idx (int) – 当前批次索引
**kwargs – 传递给
plot_prediction
的参数
- on_load_checkpoint(checkpoint: Dict[str, Any]) None [来源]#
由Lightning调用以恢复您的模型。如果您通过
on_save_checkpoint()
保存了某些内容,现在是恢复它的机会。- Parameters:
检查点 – 已加载的检查点
示例:
def on_load_checkpoint(self, checkpoint): # 99% of the time you don't need to implement this method self.something_cool_i_want_to_save = checkpoint['something_cool_i_want_to_save']
注意
Lightning会自动恢复全局步骤、时期和训练状态,包括amp缩放。 您无需恢复与训练相关的任何内容。
- on_save_checkpoint(checkpoint: Dict[str, Any]) None [来源]#
当保存检查点时由Lightning调用,以便给您一个机会来存储您可能想要保存的其他内容。
- Parameters:
checkpoint – 在保存到文件之前的完整检查点字典。该钩子的实现可以向此字典中插入额外的数据。
示例:
def on_save_checkpoint(self, checkpoint): # 99% of use cases you don't need to implement this method checkpoint['something_cool_i_want_to_save'] = my_cool_pickable_object
注意
Lightning 保存训练的所有方面(周期、全局步骤等……) 包括 amp 缩放。 您无需存储任何关于训练的信息。
- on_train_epoch_end()[来源]#
在周期结束时在训练循环中调用。
要在纪元结束时访问所有批次输出,您可以将步骤输出缓存为
LightningModule
的属性,并在此钩子中访问它们:class MyLightningModule(L.LightningModule): def __init__(self): super().__init__() self.training_step_outputs = [] def training_step(self): loss = ... self.training_step_outputs.append(loss) return loss def on_train_epoch_end(self): # do something with all training_step outputs, for example: epoch_mean = torch.stack(self.training_step_outputs).mean() self.log("training_epoch_mean", epoch_mean) # free up the memory self.training_step_outputs.clear()
- plot_prediction(x: Dict[str, Tensor], out: Dict[str, Tensor], idx: int = 0, add_loss_to_title: 指标 | Tensor | bool = False, show_future_observed: bool = True, ax=None, quantiles_kwargs: Dict[str, Any] | None = None, prediction_kwargs: Dict[str, Any] | None = None)[来源]#
绘制预测值与实际值的对比图
- Parameters:
x – 网络输入
out – 网络输出
idx – 要绘制的预测索引
add_loss_to_title – 是否将损失添加到标题或计算损失函数。可以是指标,布尔值指示是否使用损失指标,或包含所有样本损失的张量。计算的损失在没有权重的情况下确定。默认值为 False。
show_future_observed – 是否显示未来的实际值。默认为 True。
ax – 用于绘图的matplotlib坐标轴
quantiles_kwargs (字典[字符串, 任意]) –
to_quantiles()
损失度量的参数。prediction_kwargs (Dict[str, Any]) – 用于
to_prediction()
的损失指标的参数。
- Returns:
matplotlib 图形
- predict(data: DataLoader | DataFrame | 时间序列数据集, mode: str | Tuple[str, str] = 'prediction', return_index: bool = False, return_decoder_lengths: bool = False, batch_size: int = 64, num_workers: int = 0, fast_dev_run: bool = False, return_x: bool = False, return_y: bool = False, mode_kwargs: Dict[str, Any] = None, trainer_kwargs: Dict[str, Any] | None = None, write_interval: Literal['batch', 'epoch', 'batch_and_epoch'] = 'batch', output_dir: str | None = None, **kwargs) 预测 [来源]#
运行推理 / 预测。
- Parameters:
dataloader – 数据加载器、数据框或数据集
mode – “prediction”、“quantiles”或“raw”中的一个,或者元组
("raw", output_name)
,其中 output_name 是由forward()
返回的字典中的一个名称。return_index – 如果返回预测索引(与输出的顺序相同,即数据框的行对应于输出的第一维,给定的时间索引是第一个预测的时间索引)
return_decoder_lengths – 是否返回解码器长度(与输出顺序相同)
batch_size – 数据加载器的批量大小 - 仅在未传递数据加载器时使用
num_workers – dataloader 的工作线程数量 - 仅在未传递 dataloader 时使用
fast_dev_run – 是否仅返回第一批的结果
return_x – 是否返回网络输入(与预测输出的顺序相同)
return_y – 是否返回网络目标(与预测输出的顺序相同)
mode_kwargs (字典[字符串, 任意类型]) – 用于
to_prediction()
或to_quantiles()
的关键字参数,适用于“预测”和“分位数”模式trainer_kwargs (字典[字符串, 任意], 可选) – 训练器的关键字参数
write_interval – 将预测写入磁盘的时间间隔
output_dir – 用于写入预测的目录。默认值为 None。如果设置,则函数将返回空列表。
**kwargs – 网络前向方法的额外参数
- Returns:
- 如果存在
`return
参数之一, 带有字段的预测元组
prediction
,x
,y
,index
和decoder_lengths
- 如果存在
- Return type:
- predict_dependency(data: DataLoader | DataFrame | 时间序列数据集, variable: str, values: Iterable, mode: str = 'dataframe', target='decoder', show_progress_bar: bool = False, **kwargs) ndarray | Tensor | Series | DataFrame [来源]#
预测部分依赖。
- Parameters:
data (Union[DataLoader, pd.DataFrame, TimeSeriesDataSet]) – 数据
变量 (str) – 要修改的变量
values (Iterable) – 要探测的值的数组
mode (str, optional) –
输出模式。默认为“dataframe”。可以是
”series”:值为平均预测,索引为探测值
- ”dataframe”:列由 dataset.x_to_index() 方法获得,
预测(即在时间范围内的平均预测), normalized_prediction(即由第一个探测值的预测除以的预测) 探测值的变量名称
”raw”:输出形状为 len(values) x prediction_shape 的张量
target – 定义在进行预测时哪些值被覆盖。 与
set_overwrite_values()
中的相同。 默认为“decoder”。show_progress_bar – 是否显示进度条。默认为 False。
**kwargs – 传递给
predict()
方法的额外参数
- Returns:
输出
- Return type:
联合[np.ndarray, torch.Tensor, pd.Series, pd.DataFrame]
- predict_step(batch, batch_idx)[来源]#
在
predict()
期间调用的阶跃函数。默认情况下,它调用forward()
。重写以添加任何处理逻辑。该
predict_step()
用于在多个设备上进行推理缩放。为了防止OOM错误,可以使用
BasePredictionWriter
回调在每个批次结束后或在周期结束时将预测写入磁盘或数据库。在使用基于 spawn 的加速器时,应使用
BasePredictionWriter
。这发生在Trainer(strategy="ddp_spawn")
或在 8 个 TPU 核心上训练时,使用Trainer(accelerator="tpu", devices=8)
,因为预测将不会被返回。- Parameters:
batch – 数据可迭代对象的输出,通常是一个
DataLoader
。batch_idx – 该批次的索引。
dataloader_idx – 生成此批次的数据加载器的索引。
(仅在使用多个数据加载器时)
- Returns:
预测输出(可选)。
示例
class MyModel(LightningModule): def predict_step(self, batch, batch_idx, dataloader_idx=0): return self(batch) dm = ... model = MyModel() trainer = Trainer(accelerator="gpu", devices=2) predictions = trainer.predict(model, dm)
- step(x: Dict[str, Tensor], y: Tuple[Tensor, Tensor], batch_idx: int, **kwargs) Tuple[Dict[str, Tensor], Dict[str, Tensor]] [来源]#
针对每个训练/验证步骤运行。
- Parameters:
x (字典[字符串, torch.Tensor]) – 通过数据加载器传递给网络的 x
y (Tuple[torch.Tensor, torch.Tensor]) – 作为由数据加载器传递给损失函数的 y
batch_idx (int) – 批次编号
**kwargs – 除了
x
之外传递给网络的其他参数
- Returns:
- 元组,其中第一个
条目是一个字典,可以添加额外的日志结果以供在
on_epoch_end
钩子中使用,第二个条目是模型的输出。
- Return type:
元组[字典[str, torch.Tensor], 字典[str, torch.Tensor]]
- test_step(batch, batch_idx)[来源]#
在测试集上操作单个数据批次。在这一步,你通常会生成示例或计算任何感兴趣的内容,比如准确率。
- Parameters:
batch – 您的数据可迭代对象的输出,通常是一个
DataLoader
。batch_idx – 该批次的索引。
dataloader_idx – 产生此批次的dataloader的索引。 (仅在使用多个dataloader时)
- Returns:
Tensor
- 损失张量dict
- 一个字典。可以包含任何键,但必须包含键'loss'
。None
- 跳到下一个批次。
# if you have one test dataloader: def test_step(self, batch, batch_idx): ... # if you have multiple test dataloaders: def test_step(self, batch, batch_idx, dataloader_idx=0): ...
示例:
# CASE 1: A single test dataset def test_step(self, batch, batch_idx): x, y = batch # implement your own out = self(x) loss = self.loss(out, y) # log 6 example images # or generated text... or whatever sample_imgs = x[:6] grid = torchvision.utils.make_grid(sample_imgs) self.logger.experiment.add_image('example_images', grid, 0) # calculate acc labels_hat = torch.argmax(out, dim=1) test_acc = torch.sum(y == labels_hat).item() / (len(y) * 1.0) # log the outputs! self.log_dict({'test_loss': loss, 'test_acc': test_acc})
如果您传入多个测试数据加载器,
test_step()
将有一个额外的参数。我们建议将默认值设置为 0,以便您能够快速在单个和多个数据加载器之间切换。# CASE 2: multiple test dataloaders def test_step(self, batch, batch_idx, dataloader_idx=0): # dataloader_idx tells you which dataset this is. ...
注意
如果你不需要测试,就不需要实现这个方法。
注意
当调用
test_step()
时,模型已被置于评估模式,并且 PyTorch 梯度已被禁用。在测试循环结束时,模型返回到训练模式,梯度被启用。
- to_prediction(out: Dict[str, Any], use_metric: bool = True, **kwargs)[来源]#
使用损失指标将输出转换为预测。
- Parameters:
out (字典[字符串, 任意]) – 网络的输出,其中“预测”经过
transform_output()
转换use_metric (bool) – 是否使用指标进行转换,如果为 False,则简单地对
out["prediction"]
进行平均**kwargs – 传递给度量
to_quantiles
方法的参数
- Returns:
预测形状为 batch_size x timesteps
- Return type:
torch.Tensor
- to_quantiles(out: Dict[str, Any], use_metric: bool = True, **kwargs)[来源]#
使用损失指标将输出转换为分位数。
- Parameters:
out (字典[字符串, 任意类型]) – 网络的输出,其中“预测”已经通过
transform_output()
进行了转换use_metric (bool) – 是否使用指标进行转换,如果为 False,简单地对
out["prediction"]
取分位数**kwargs – 传递给度量
to_quantiles
方法的参数
- Returns:
形状为 batch_size x timesteps x n_quantiles 的分位数
- Return type:
torch.Tensor
- transform_output(prediction: Tensor | List[Tensor], target_scale: Tensor | List[Tensor], loss: 指标 | None = None) Tensor [来源]#
从网络输出中提取预测并将其重新缩放到真实空间/去规范化它。
- Parameters:
预测 (Union[torch.Tensor, List[torch.Tensor]]) – 归一化的预测
target_scale (Union[torch.Tensor, List[torch.Tensor]]) – 用于重新缩放预测的比例
损失 (可选[指标]) – 用于转换的指标
- Returns:
重新缩放的预测
- Return type:
torch.Tensor
- validation_step(batch, batch_idx)[来源]#
对验证集中的单个数据批次进行操作。在这一步中,您可能会生成示例或计算任何感兴趣的内容,例如准确性。
- Parameters:
batch – 您的数据可迭代对象的输出,通常是一个
DataLoader
。batch_idx – 该批次的索引。
dataloader_idx – 生成此批次的数据加载器的索引。
(仅在使用多个数据加载器时)
- Returns:
Tensor
- 损失张量dict
- 一个字典。可以包含任何键,但必须包含键'loss'
。None
- 跳到下一个批次。
# if you have one val dataloader: def validation_step(self, batch, batch_idx): ... # if you have multiple val dataloaders: def validation_step(self, batch, batch_idx, dataloader_idx=0): ...
示例:
# CASE 1: A single validation dataset def validation_step(self, batch, batch_idx): x, y = batch # implement your own out = self(x) loss = self.loss(out, y) # log 6 example images # or generated text... or whatever sample_imgs = x[:6] grid = torchvision.utils.make_grid(sample_imgs) self.logger.experiment.add_image('example_images', grid, 0) # calculate acc labels_hat = torch.argmax(out, dim=1) val_acc = torch.sum(y == labels_hat).item() / (len(y) * 1.0) # log the outputs! self.log_dict({'val_loss': loss, 'val_acc': val_acc})
如果您传入多个 val 数据加载器,
validation_step()
将会有一个额外的参数。我们建议将默认值设置为 0,这样您可以快速在单个和多个数据加载器之间切换。# CASE 2: multiple validation dataloaders def validation_step(self, batch, batch_idx, dataloader_idx=0): # dataloader_idx tells you which dataset this is. ...
注意
如果您不需要验证,则无需实现此方法。
注意
当调用
validation_step()
时,模型已被设置为评估模式并且 PyTorch 梯度已被禁用。在验证结束时,模型返回训练模式并启用梯度。
- property current_stage: str#
可在闪电循环中使用。
:返回:当前训练者阶段。可选项包括 [“train”, “val”, “test”, “predict”, “sanity_check”]
- property log_interval: float#
日志间隔取决于是训练还是验证
- property n_targets: int#
要预测的目标数量。
基于损失函数。
- Returns:
目标数量
- Return type:
整数
- property target_names: List[str]#
预测的目标列表。
- Returns:
目标名称列表
- Return type:
列表[str]