After some discussion , I think the reason is :
Normally , for one-label image , dataset return the label (type:list) , and dataLoader make it turn to tensor .
But for multi-label image , dataLoader can’t turn it to tensor , which cause a bug we meet before : type ‘list’ doesn’t have the attribute ‘to’. (the code that makes it is “target.to(device)”)
To fix that problem , we use torch.from_numpy to turn it to tensor in dataset
lableList = list(map(int, words))
			lableList = np.array(lableList)
			lableList = torch.from_numpy(lableList)
			imgs.append((imageList, lableList))
		self.imgs = imgs

And here is the problem . The number of our image’s labels is not certain (some pictures got 3 , some got 4, some 2),and that makes the length of the labeList is not certain .When it turn to tensor , the dimension 0 is not certain (some 3,some 2), and this is the reason that cause the error.
Is my thought right ? If so , how can I solve the problem caused by “number of labels is not certain” ?
Appreciate for reply!