New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NotImplemented Error while running ImbalancedDatasetSampler #18
Comments
Having the same issue - no detailed error message, just a It looks like the code only supports MNIST, Subsets, or an |
If anyone reads this, this worked for me:
Edit: I suspect it would be faster to not cast the tensor to numpy, so the following change should do the same within the tensor framework:
|
If you have an int label, try use this:
|
For those who are new to Python like me: define the 'callback_get_label' function before you initialize the train_loader, and make your function like: |
@ufoym this is solved, can be closed 🐰 |
@Borda Thanks pretty much for your contribution! |
I got this error: could you tell where to define the callback_get_label() function? |
This?
def callback_get_label(dataset, idx):
#callback function used in imbalanced dataset loader.
i, target = dataset[idx]
return int(target)
…On Thu, May 19, 2022 at 2:18 AM xong ***@***.***> wrote:
If you have an int label, try use this:
def callback_get_label(dataset, idx):
#callback function used in imbalanced dataset loader.
i, target = dataset[idx]
return int(target)
For those who are new to Python like me: define the 'callback_get_label'
function before you initialize the train_loader, and make your function
like: train_loader = DataLoader(dataset,
ImbalancedDatasetSampler(dataset,callback_get_label =
callback_get_label),batch_size = batch_size)
I got this error:
TypeError: callback_get_label() missing 1 required positional argument:
'idx'
could you tell where to define the callback_get_label() function?
—
Reply to this email directly, view it on GitHub
<#18 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/APLVASGMETIEKAM4C7LO7YTVKUX6DANCNFSM4OBNKJSQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I followed the steps exactly according to the readme file. Yet I am getting a notimplemented error. There's no explanation for the error as well.
Here's my code:
`from torchvision import transforms
from torchsampler import ImbalancedDatasetSampler
batch_size = 128
val_split = 0.2
shuffle_dataset=True
random_seed=42
dataset_size = len(melanoma_dataset)
indices = list(range(dataset_size))
split = int(np.floor(val_split * dataset_size))
if shuffle_dataset :
np.random.seed(random_seed)
np.random.shuffle(indices)
train_indices, test_indices = indices[split:], indices[:split]
train_loader = torch.utils.data.DataLoader(melanoma_dataset,batch_size=batch_size,sampler=ImbalancedDatasetSampler(melanoma_dataset))
test_loader = torch.utils.data.DataLoader(melanoma_dataset,batch_size=batch_size,sampler=test_sampler)`
The text was updated successfully, but these errors were encountered: