I tried now

    target = target.float()
    target = Variable(target)
    data = Variable(data)
    optimizer.zero_grad()
    
    output = model(data)
    criterion = nn.MSELoss()
    loss = criterion(output,target)


and get

RuntimeError: input and target have different number of elements: input[64 x 784] has 50176 elements, while target[64] has 64 elements at /b/wheel/pytorch-src/torch/lib/THNN/generic/MSECriterion.c:12