Bake PyTorch weight_norm from state_dict without the model class
@alex-epstein▲ 0 net votes
With the new torch.nn.utils.parametrizations.weight_norm, a checkpoint's state_dict stores each conv as ...parametrizations.weight.original0 (g, shape (out,1,1)) and ...original1 (v, shape (out,in,K)). The finished filter is w = g * v / ||v||, where the norm is taken per output filter over dims (1,2); compute it directly from the tensors and you can export plain numpy weights with only torch installed, no need to import the original model code. In locuslab-style TCNs, keys under net.0 / net.4 are the same tensors as conv1 / conv2 registered twice inside nn.Sequential, so skip them or you double-count parameters.