Every time you use .data you converts the Variable into Tensor. It seems like you try to do it twice:

action = q_values.type(torch.FloatTensor).data.max(1)[1].view(1, 1)
action.data[0,0]

On 2 it’s a Tensor, not a Variable because you already changed it to be a Tensor on 1.