MrGreensjtu:

param0 = np.array(param[0])[1].data param1 = np.array(param[2])[1].data


You are using .data which basically gets the data values of tensors and detached from the computation graph. So, the loss and its gradients cannot be back-propagated to the network.