Hi @bing,
When using pred = output.data.max(1, keepdim=True)[0] the 0 index is the maximum value and the first index the argmax. You probably want to compare the argmax of your predictions with your target labels, so  pred = output.data.max(1, keepdim=True)[1] should work.