I have found out that the loss was too high due to the random weight initialisation and the weight values were too high ,loss is low and decreasing after every iteration  but to my utter dismay  all the predictions are only restricted to one class in each iteration.
I am using log_softmax and nll_loss as the activation function and loss function respectively.