Using m.weight
without .data
and plain
loss = loss + 0.01*li_reg_loss
lets pytorch keep track of the trail between weights and loss for backpropagation.
Using .data
and rewrapping in a variable cuts the connection.
Best regards
Thomas