Could you print the shapes of inputs and val_h in your validiation loop before passing them to your model?
The core runs fine if I use random inputs, so there seems to be some kind of shape mismatch coming from the valid_loader.
EDIT: You are currently using nn.Softmax as your last activation and nn.NLLLoss as your criterion.
Note that nn.NLLLoss expects nn.LogSoftmax as inputs, so you should change this activation.