hey from looks of it when you are creating the hx, and cx Variables you have set the size incorrectly
u will want something like this:
cx = Variable(torch.zeros(1, 512))
hx = Variable(torch.zeros(1, 512))
As I see you are using my repo as reference it would be those lines in the train.py 3 and test.py 1 file