From 489b8a853746bcf047bc328bfaf413292e2ab23d Mon Sep 17 00:00:00 2001 From: vasanthadithya Date: Tue, 12 May 2026 22:46:45 +0530 Subject: [PATCH] Modernize introyt models tutorial --- beginner_source/introyt/modelsyt_tutorial.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/beginner_source/introyt/modelsyt_tutorial.py b/beginner_source/introyt/modelsyt_tutorial.py index c6f24514b42..3dbb38c13c2 100644 --- a/beginner_source/introyt/modelsyt_tutorial.py +++ b/beginner_source/introyt/modelsyt_tutorial.py @@ -48,12 +48,12 @@ class is a subclass of ``torch.Tensor``, with the special behavior that class TinyModel(torch.nn.Module): def __init__(self): - super(TinyModel, self).__init__() + super().__init__() self.linear1 = torch.nn.Linear(100, 200) self.activation = torch.nn.ReLU() self.linear2 = torch.nn.Linear(200, 10) - self.softmax = torch.nn.Softmax() + self.softmax = torch.nn.Softmax(dim=1) def forward(self, x): x = self.linear1(x) @@ -150,7 +150,7 @@ def forward(self, x): class LeNet(torch.nn.Module): def __init__(self): - super(LeNet, self).__init__() + super().__init__() # 1 input image channel (black & white), 6 output channels, 5x5 square convolution # kernel self.conv1 = torch.nn.Conv2d(1, 6, 5) @@ -249,7 +249,7 @@ def num_flat_features(self, x): class LSTMTagger(torch.nn.Module): def __init__(self, embedding_dim, hidden_dim, vocab_size, tagset_size): - super(LSTMTagger, self).__init__() + super().__init__() self.hidden_dim = hidden_dim self.word_embeddings = torch.nn.Embedding(vocab_size, embedding_dim)