English version:To simplify the problem, if my network consists of two blocks, each consisting of a convolutional layer and a linear transformation layer, but when defining the model, I only instantiate one linear transformation layer, and the two linear transformation layers are actually one object. In this way, I call the model. parameters() method to obtain a parameter set of convolution 2+linear 1=3 (without considering bias). But using paramwise After the cfg option, the add of the defaultOptimWrapperConstructor will be called The params method yields a parameter set of convolution 2+linear 2=4. I only save parameter groups based on the network structure, but I don't realize that some layers are actually an object. Using add_ When the parameter group obtained by the params method is fed into the adam optimizer, an error will be reported: some parameters appear in more than one parameter group. Because the linear layer was saved once more.
Reproduces the problem - code sample
I gave a simplified example of the problem with the model I built myself
Reproduces the problem - command or script
I gave a simplified example of the problem with the model I built myself
Reproduces the problem - error message
some parameters appear in more than one parameter group
Additional information
Hope to solve this bug.The add_params method should return the same value as the Model.parameter () method.
Prerequisite
Environment
English version:To simplify the problem, if my network consists of two blocks, each consisting of a convolutional layer and a linear transformation layer, but when defining the model, I only instantiate one linear transformation layer, and the two linear transformation layers are actually one object. In this way, I call the model. parameters() method to obtain a parameter set of convolution 2+linear 1=3 (without considering bias). But using paramwise After the cfg option, the add of the defaultOptimWrapperConstructor will be called The params method yields a parameter set of convolution 2+linear 2=4. I only save parameter groups based on the network structure, but I don't realize that some layers are actually an object. Using add_ When the parameter group obtained by the params method is fed into the adam optimizer, an error will be reported: some parameters appear in more than one parameter group. Because the linear layer was saved once more.
Reproduces the problem - code sample
I gave a simplified example of the problem with the model I built myself
Reproduces the problem - command or script
I gave a simplified example of the problem with the model I built myself
Reproduces the problem - error message
some parameters appear in more than one parameter group
Additional information
Hope to solve this bug.The add_params method should return the same value as the Model.parameter () method.