I’m doing transfer learning with pytorch and I did it this way, is it correct?
start=time.time()
print("Transfer Learning Eğitimi Başlıyor")
print("----------------------------------------------")
import torchvision.models as models


model = models.densenet161(pretrained=True) # Önceden eğitilmiş modelleri kullanmak için pretrained=True 

for param in model.parameters(): # Tüm modeli eğitmek için True
    param.requires_grad = False # Parametreleri donduruyoruz

model.classifier=nn.Sequential(
    
nn.Linear(2208,1000),
nn.ReLU(inplace=True),
nn.Linear(1000,500),
nn.ReLU(inplace=True),
nn.Linear(500,200),
nn.ReLU(inplace=True),
nn.Linear(200,100),
nn.ReLU(inplace=True),
nn.Linear(100,50),
nn.ReLU(inplace=True),
nn.Linear(50,20),
nn.ReLU(inplace=True),
nn.Linear(20,10),
nn.ReLU(inplace=True),
nn.Linear(10,4)
)


error = nn.CrossEntropyLoss()
optimizer = optim.Adam(model.parameters(), lr=0.001)

epoch=1
count=0
iterasyon=[]
for i in range(epoch):

    for i,(images,label) in enumerate (train_loader):
        
        out = model(images)
        loss = error(out, label)

        optimizer.zero_grad()
        loss.backward()
        optimizer.step()
        
        count+=1
        
        if count % 20 == 0:
            iterasyon.append(count)
            print("İterasyon:{}--loss:{:.4f}".format(count,loss.item()))

print("Transfer Learning Eğitimi Bitti")
print("----------------------------------------------")            
end=time.time()
print("süre:",end-start)