I corrected the above error but now I get another one saying :
RuntimeError: only batches of spatial targets supported (3D tensors) but got targets of dimension: 4 at /data/users/soumith/miniconda2/conda-bld/pytorch-0.1.7_1485444530918/work/torch/lib/THCUNN/generic/SpatialClassNLLCriterion.cu:17

I get what the error is, but I need to use the above function for my image labels : 410x1x512x1024 a 4D Vector.
Is there a workaround to do so.