Wrong classification of Python — assertion cur_ Target is greater than or equal to 0 and cur_ Target is less than n_ classes failed

RuntimeError: Assertion `cur_target >= 0 && cur_target < n_classes' failed.  at c:\programdata\miniconda3\conda-bld\pytorch-cpu_1532498166916\work\aten\src\thnn\generic/ClassNLLCriterion.c:93

The

assertion function returns an error, requiring the target class to be greater than or equal to 0 and less than or equal to the input class, but not satisfying.
often encounter this problem in classification training. Generally speaking, this error will occur when the number of categories output in our network is different from the number of categories set by your label.

USES find to remove background class 0 in experimental classification on matlab, so all categories start from 1. There is no problem in classification on matlab, but Pytorch has a requirement that the label must start with 0 when CrossEntropyLoss is used for verification, so it will give an error

please

in

place

Richard

After the

back

scene

class

the

after

will

the

There are

the

class

Don’t

mark

sign

Reduction of

1

\ leftarRow Subtracting all category labels by 1 after processing the background class

please in at Daniel the back view class of by a class not tag sign reduction 1

Read More: