shenweichen / DeepCTR-Torch

【PyTorch】Easy-to-use,Modular and Extendible package of deep-learning based CTR models.
https://deepctr-torch.readthedocs.io/en/latest/index.html
Apache License 2.0
2.95k stars 696 forks source link

训练过程中有一定概率因为label全为0而报错 #266

Open BarryRun opened 1 year ago

BarryRun commented 1 year ago

Describe the bug(问题描述) 根据这里 的代码,在verbose>0时,需要计算当前batch上的metric。而在特殊情况下,例如最后一个batch刚好只有几条label为0的数据时,会出现以下报错:

ValueError: y_true contains only one label (0.0). Please provide the true labels explicitly through the labels argument.

是否可以在trainer中添加让dataloader分布均匀的代码?

11101028 commented 1 year ago

可以在basemodel.py的第268行加try,如果lable全为0就跳过