'STL10' object has no attribute 'targets'

I’m trying to access the targets attribute of an STL 10 object (after loading the dataset successfully). My code is

dataset_tgt = datasets.STL10(root='./data',

idx = dataset_tgt.targets == label
dataset_tgt.targets = dataset_tgt.targets[idx]
dataset_tgt.data = dataset_tgt.data[idx]

And I get the error ‘STL10’ object has no attribute ‘targets’. I tried to replace targets with train_labels but the error persists. Any help would be great! Thank you guys so much!!

Problem solved by changing targets to labels.