The issue is most likely created by the usage of numpy arrays in the undefined q_net.
Since you are calling from_numpy on the output of q_net here:
torch.from_numpy(q_net(elem,self.q_params)).float()

I assume that internally numpy will be used, which will detach these operations from the computation graph and self.q_params won’t get any gradients.
You could either use PyTorch methods in q_net or write custom autograd.Functions as described here 3.