0PricingLogin
Deep Learning Academy · Lesson

nn.Sequential for Quick Models

Chain layers without a custom class.

A Shortcut for Simple Nets

When data flows straight through layers in order, nn.Sequential lets you skip writing a full custom class.

List Your Layers in Order

You pass the layers as arguments, and Sequential runs them one after another. The order you list them is the order they execute.

model = nn.Sequential(
    nn.Linear(4, 16),
    nn.ReLU(),
    nn.Linear(16, 3))

All lessons in this course

  1. Subclass nn.Module: __init__ and forward
  2. Stacking Linear Layers
  3. nn.Sequential for Quick Models
  4. Inspect Parameters and Layer Shapes
← Back to Deep Learning Academy