Problem
I was trying to enumerate through a
torch.utils.data.DataLoader
object, where it takes self-defined
dataset_
as a parameter. The dataset looks like this:
dataset_.append((img, raw_label, target_label, is_backdoor, acc, conf))
.
Printing
print(type(img),type(raw_label),type(target_label),is_backdoor,type(is_clean_acc),type(conf))
yields
<class 'torch.Tensor'> <class 'torch.Tensor'> <class 'int'> <class 'bool'> <class 'bool'> <class 'float'>
. Note, however, that the class of
target_label
(
int
) is inconsistent with the class of
raw_label
(
tensor
).
Solution
Inspired by the blog