Bert-Chinese-Text-Classification-Pytorch icon indicating copy to clipboard operation
Bert-Chinese-Text-Classification-Pytorch copied to clipboard

你好 我想问你一下 换成自己的数据集 为什么总会出现 ValueError: too many values to unpack (expected 2) 想问一下怎么解决

Open ZMM6128 opened this issue 5 years ago • 2 comments

ZMM6128 avatar Jul 01 '20 03:07 ZMM6128

我也是这样,看了下代码好像是因为每条数据都要定长成pad_size,用\t来增补。但是我也不知道怎么解决,请问您解决了吗?

wusaisa avatar Dec 31 '20 01:12 wusaisa

因为你的数据集有空行,你可以将以下代码的路径换成你的数据集,报错就知道在哪是空行了 with open(r"D:\weibo\Bert-Chinese-Text-Classification-Pytorch-master\THUCNews\data\train.txt", 'r', encoding='UTF-8') as f: for line in tqdm(f): lin = line.strip() if not lin: continue content, label = lin.split('\t') print(content)

minimory avatar Jan 19 '21 03:01 minimory