Creates a deep copy of (i.e. not just a pointer to) the module, including the current state of its parameters (e.g. weight, biases etc., if any).
If arguments are provided to the clone(...)
function it also calls share(...)
with those arguments on the cloned module after creating it, hence making a deep copy of this module with some shared parameters.
Example:
-- make an mlp mlp1=nn.Sequential(); mlp1:add(nn.Linear(100,10)); -- make a copy that shares the weights and biases mlp2=mlp1:clone('weight','bias'); -- we change the bias of the first mlp mlp1:get(1).bias[1]=99; -- and see that the second one's bias has also changed.. print(mlp2:get(1).bias[1])