Skip to content

Assertion `cur_target >= 0 && cur_target < n_classes' failed #1

@abenchaaben

Description

@abenchaaben

Hi,
Thank you for your project. It's helpful. I'm tried to launch your train.py script on a new dataset and i have encounter the following error

File "src/train.py", line 60, in
metric_list=metric_list, verbose=True)
File "/workspace/src/unet/model.py", line 186, in fit_dataset
train_logs = self.fit_epoch(dataset, n_batch=n_batch, shuffle=shuffle)
File "/workspace/src/unet/model.py", line 99, in fit_epoch
training_loss = self.loss(y_out, y_batch)
File "/usr/local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "/workspace/src/unet/metrics.py", line 25, in forward
ignore_index=self.ignore_index)
File "/usr/local/lib/python3.6/site-packages/torch/nn/functional.py", line 2056, in cross_entropy
return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction)
File "/usr/local/lib/python3.6/site-packages/torch/nn/functional.py", line 1873, in nll_loss
ret = torch._C._nn.nll_loss2d(input, target, weight, _Reduction.get_enum(reduction), ignore_index)
RuntimeError: Assertion `cur_target >= 0 && cur_target < n_classes' failed. at /pytorch/aten/src/THNN/generic/SpatialClassNLLCriterion.c:109

As i search in the internet for the cause, i find that maybe it's the dimensions of the output layer. The problem is thta i did not change anything and i used a similar dataset

Thank you for your help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions