赞
踩
传入参数搞错了
计划通过一个下标list,通过rand.shuffle实现训练数据的随机化,结果因为传入的数据是没有tokenized的(就是一堆原始的字符串,并且是用list保存的,tokenize之后应该是一个torch.tensor类型的张量)
对应原因,传入正确的参数即可
python原生的list不支持使用一个int型list作为下标进行访问,
pytorch的张量支持这样访问
可能torch是基于numpy设计的,numpy中的数组也支持这样访问
如图,list会报错
而np数组和 torch的张量均不会报错
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。