'MyDataset' object has no attribute 'get_labels'
See original GitHub issueWhen I try to use my own Dataset class, I get the error 'MyDataset' object has no attribute 'get_labels'
and cannot proceed.
The content of the Dataloader is as follows, and there is nothing strange about it. It processes the image data and label data in .npz format.
class MyDataset(data.Dataset):
def __init__(self, images, labels, transform=None):
self.images = images
self.labels = labels
self.transform = transform
def __len__(self):
return len(self.images)
def __getitem__(self, index):
image = self.images[index]
label = self.labels[index]
if self.transform is not None:
image = self.transform(image=image)["image"]
return image, label
train_dataset = MyDataset(train_imgs, train_labels, transform=transform)
train_dataloader = torch.utils.data.DataLoader(train_dataset,
sampler=ImbalancedDatasetSampler(train_dataset),
batch_size= batch_size,
shuffle=True,
num_workers=2)
Is there something wrong with the code? I don’t think it’s a typo.
How can I fix it so that it works correctly?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
'MyDataset' object has no attribute 'get_labels' #34 - bytemeta
When I try to use my own Dataset class, I get the error 'MyDataset' object has no attribute 'get_labels' and cannot proceed.
Read more >ConcatDataset support · Issue #37 - GitHub
I try to combine two datasets by using "dataset = dataset1+dataset2", ... object has no attribute 'get_labels' Is there any workaround?
Read more >python - Get labels from dataset when using tensorflow ...
My images are organized in directories having the label as the name. The documentation says the function returns a tf.data.Dataset object. If ...
Read more >get_labels: Retrieve value labels of labelled data in sjlabelled
View source: R/get_labels.R ... If x has no label attributes, factor levels are returned. ... values are set as names attribute of the...
Read more >lightgbm.Dataset — LightGBM 3.3.3.99 documentation
Get a chain of Dataset objects. Starts with r, then goes to r.reference (if exists), then to r.reference.reference, etc. until we hit ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
add this in your dataset code, and turn off the shuffle
def get_labels(self): return self.labels