Model
Learn about the model class and the different types of functions that come along with it.
Introduction to models
In PyTorch, a model is represented by a regular Python class that inherits from the Module
class.
IMPORTANT: Are you comfortable with object-oriented programming (OOP) concepts like classes, constructors, methods, instances, and attributes?
If you are unsure about any of these terms, we strongly recommend that you first brush up your skills in OOP before proceeding.
Having a good understanding of OOP is key to benefit the most from PyTorch’s capabilities.
So, assuming you are already comfortable with OOP, let us dive into developing a model in PyTorch.
The most fundamental methods a model class needs to implement are:
__init__(self)
: It defines the parts that make up the model; in our case, two parameters ofb
andw
.
...
You are not limited to defining parameters though. Models can contain other models as their attributes as well, so you can ...