Git Product home page Git Product logo

Comments (1)

SamuelLarkin avatar SamuelLarkin commented on May 11, 2024

The trigger for this was a deprecation message warnings.warn("torch.nn.utils.weight_norm is deprecated in favor of torch.nn.utils.parametrizations.weight_norm.").
If we look at weight_norm's documentation, it doesn't mention that we now have to use remove_parametrizations. I found out about that fact by trying to diff nn/utils/weight_norm.py nn/utils/parametrizations.py and noticing that the documentation, in the code, for weight_norm() says

* To remove the weight normalization reparametrization, use
   :func:`torch.nn.utils.parametrize.remove_parametrizations`.

Starting from torch.nn, it appears that the link for weight_norm is broken as it doesn't bring weight_norm's documentation but rather simply brings us to the end of the page. But if we search for weight_norm and then click on torch.nn.utils.parametrizations.weight_norm, we get some documentation but no mention of having to use remove_paramatrizations() like it is said in the code itself.

Using weight_norm() with remove_parametrizations() we get the expected behavior.

#!/usr/bin/env  python3
# coding: utf-8
#
from torch.nn import ConvTranspose1d
from torch.nn.utils.parametrizations import weight_norm
from torch.nn.utils.parametrize import remove_parametrizations

c = ConvTranspose1d(512, 256, kernel_size=(16,), stride=(8,), padding=(4,))
print(c)
m = weight_norm(c)
print(m)
remove_parametrizations(m, "weight")
ConvTranspose1d(512, 256, kernel_size=(16,), stride=(8,), padding=(4,))
ParametrizedConvTranspose1d(
  512, 256, kernel_size=(16,), stride=(8,), padding=(4,)
  (parametrizations): ModuleDict(
    (weight): ParametrizationList(
      (0): _WeightNorm()
    )
  )
)

from pytorch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.