Model Types
Learn about the different types of models that are present in Deep Learning.
Nested models
In our model, we manually created two parameters to perform a linear regression. Instead of defining individual parameters, what if we use PyTorch’s Linear
model?
We are implementing a single feature linear regression, one input, and one output, so the corresponding linear model would look like this:
Press + to interact
Python 3.5
import torch.nn as nnlinear = nn.Linear(1, 1)print(linear)
Do we still have our b
and w
parameters? Sure we do!
Press + to interact
Python 3.5
import torch.nn as nnlinear = nn.Linear(1, 1)print(linear.state_dict())
So, our former parameter b
is the bias, and our former parameter w
is the weight. Your values will be different since random seed has not been set up for this example. ...