That error is from deep inside the pytorch source code. The offending line in the model seems to be x = F.relu(self.fc1(state))
My guess is that Qnetwork was initialised with an input_size that doesn’t match the size of the state it receives.
Going a little furthur…
input = Variable(torch.from_numpy(np.array([series[0].state, series[-1].state], dtype = np.float32)))

somehow produces a 1d tensor containing only 2 elements.
That must mean that series[0].state is a number rather than a vector of 20 numbers.