There was a similar issue here too, but I am having trouble understanding this

  
    
    
    RuntimeError: assigned grad has data of a different type autograd
  
  
    I am trying to assign a ndarray of zeros to the grad of the model parameters, but I am getting the error in the title. 
I was just trying to see if I can assign a numpy array to the param.grad. But in my project I won’t be assigning zeros actually. 
for param in model.parameters():
            #print(param.grad)
            param.grad = torch.from_numpy(np.zeros(param.grad.shape)).type(param.grad.dtype)

I am trying to do this step after loss.backward() step. 
I want to know what is causing this…