BaşlayınÜcretsiz Başlayın

Accessing the model parameters

A PyTorch model created with the nn.Sequential() is a module that contains the different layers of your network. Recall that each layer parameter can be accessed by indexing the created model directly. In this exercise, you will practice accessing the parameters of different linear layers of a neural network.

Bu egzersiz

Introduction to Deep Learning with PyTorch

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Access the weight parameter of the first linear layer.
  • Access the bias parameter of the second linear layer.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

model = nn.Sequential(nn.Linear(16, 8),
                      nn.Linear(8, 2)
                     )

# Access the weight of the first linear layer
weight_0 = ____
print("Weight of the first layer:", weight_0)

# Access the bias of the second linear layer
bias_1 = ____
print("Bias of the second layer:", bias_1)
Kodu Düzenle ve Çalıştır