UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead. warnings.warn("nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.")

Ask Questions Forum: ask Machine Learning Questions to our readersCategory: PyTorchUserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead. warnings.warn("nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.")
Chris Staff asked 5 months ago

I’m getting this error. How can I solve it?

1 Answers
Best Answer
Chris Staff answered 5 months ago

Strictly speaking, this is not an error – but a warning instead. It tells you that nn.functional.sigmoid is deprecated, meaning that it is no longer supported by the current PyTorch API, and that it may be removed in the future.
 
It was deprecated because “tensors and variables are now merged” – per one of the PyTorch developers.
 
So far, it still works, but you might best replace it with nn.Sigmoid instead, like this:
 

    def __init__(self):
      super().__init__()
      self.layers = nn.Sequential(
        nn.Linear(28 * 28, 256),
        nn.Sigmoid(),
        nn.Linear(256, 128),
        nn.Tanh(),
        nn.Linear(128, 56),
        nn.ReLU(),
        nn.Linear(56, 10)
      )

 

Your Answer

6 + 12 =