Why is torch.nn.Sigmoid a class instead of a method?
I'm trying to understand how pytorch works a little bit better. Usually, when defining a neural network class, in the init() constructor, people write self.sigmoid = nn.Sigmoid(), so that in the forward() method they can call the sigmoid function multiple times with having to reinstantiate nn.Sigmoid() every time.

But why isn't nn.Sigmoid just a method to begin with, instead of a class?

Also, I was curious what to refer to 'nn' in torch.nn as (package? library?).

Thanks!

My understanding is that the nn.Sigmoid exists to be composable with other nn layers, like this:

net = nn.Sequential(
      nn.Linear(3, 4),
      nn.Sigmoid())


If you don't need this, you can just use torch.sigmoid function.
