I have a question for the implementation of Dblock and DBlockOptimized. When I was trying to visualize the spectral norm of some layers, I noticed that you have two version of implementation of SN: class SNConv2d in torch_mimicry/modules/spectral_norm.py and function SNConv2d in torch_mimicry/modules/layers.py. If it is true, in Dblock and DBlockOptimized, class SNConv2d with spectral_norm=True by default. However, I feel little confused when i run the following code:
Simply the following lines:
from torch_mimicry.modules.resblocks import DBlockOptimized, DBlock, GBlock
if __name__ == "__main__":
block = DBlockOptimized(3,128)
print(block)
I checked Conv2d in that block and it seems that it implemented SN using pytorch official spectral norm since the Conv2d has attribute weight_orig, which origins from pytorch official implementation.
Copied the whole file of torch_mimicry/modules/resblocks.py and add the following lines:
######
...
contents of resblock.py
...
######
## adding the following lines
if __name__ == "__main__":
block = DBlockOptimized(3,128)
print(block)
here the SN is implemented as in class SNConv2d by the author.
Since class SNConv2d has a more convenient way to inspect the spectral norm(it has related function to do this directly), I wonder what caused this difference. Also when I call SNGANDiscriminator32 and print its modules, results show that all the SN conv2d is implemented by pytorch official SN function/wrapper. If you've already figured it out, plz tell me how to switch to class SNConv2d .
Hi~ thanks for your great contribution!
I have a question for the implementation of
Dblock
andDBlockOptimized
. When I was trying to visualize the spectral norm of some layers, I noticed that you have two version of implementation of SN: classSNConv2d
intorch_mimicry/modules/spectral_norm.py
and functionSNConv2d
intorch_mimicry/modules/layers.py
. If it is true, inDblock
andDBlockOptimized
, classSNConv2d
withspectral_norm=True
by default. However, I feel little confused when i run the following code:Simply the following lines:
the output was:
I checked
Conv2d
in that block and it seems that it implemented SN using pytorch official spectral norm since theConv2d
has attributeweight_orig
, which origins from pytorch official implementation.Copied the whole file of torch_mimicry/modules/resblocks.py and add the following lines:
the output was:
here the SN is implemented as in class
SNConv2d
by the author.Since class
SNConv2d
has a more convenient way to inspect the spectral norm(it has related function to do this directly), I wonder what caused this difference. Also when I callSNGANDiscriminator32
and print its modules, results show that all the SN conv2d is implemented by pytorch official SN function/wrapper. If you've already figured it out, plz tell me how to switch to classSNConv2d
.THANKS!