Hello. I want to transfer learning with pytorch but my error rate is increasing and decreasing abnormally and my accuracy rate is not increasing. Am I doing something wrong? Yield is 19201080 but due to lack of memory there are 2828 and formula 1 car images
note=The ready models and weights I use are not suitable for my dataset. what do you think
import torchvision.models as models
model = models.resnet152(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
num_ftrs = model.fc.in_features
model.fc = nn.Linear(num_ftrs, 100)
model.fc2=nn.ReLU()
model.fc3=nn.Linear(100,20)
model.fc4=nn.ReLU()
model.fc5=nn.Linear(20,10)
model.fc6=nn.ReLU()
model.fc7=nn.Linear(10,4)
error = nn.CrossEntropyLoss()
optimizer = optim.Adamax(model.parameters(), lr=0.0001)
num_epochs=20
count=0
losses = []
iterasyon=[]
for epoch in range(num_epochs):
for i,(images,label) in enumerate (train_loader):
out = model(images)
loss = error(out, label)
optimizer.zero_grad()
loss.backward()
optimizer.step()
losses.append(loss.item())
count+=1
if count % 200 == 0:
total=0
correct=0
correct_hata=0
for image,labels in test_loader:
out=model(images)
pred=torch.max(out.data,1)[1]
total+=len(label)
correct+= (pred==labels).sum()
correct_hata+=(pred!=labels).sum()
dogruluk=100*correct /float(total)
hata=100*correct_hata /float(total)
losses.append(loss.data)
iterasyon.append(count)
if count % 200 == 0:
print('Iteration: {} Loss: {} Accuracy: {}% Error: {}%'.format(count, loss.data, dogruluk,hata))
```
result:
Iteration: 200 Loss: 1.5698899030685425 Accuracy: 27.848100662231445% Error: 72.15190124511719%
Iteration: 400 Loss: 1.530423879623413 Accuracy: 26.582279205322266% Error: 73.417724609375%
Iteration: 600 Loss: 1.5104633569717407 Accuracy: 26.582279205322266% Error: 73.417724609375%
Iteration: 800 Loss: 1.3361421823501587 Accuracy: 27.848100662231445% Error: 72.15190124511719%
Iteration: 1000 Loss: 1.297659158706665 Accuracy: 20.253164291381836% Error: 79.74683380126953%
Iteration: 1200 Loss: 1.3579907417297363 Accuracy: 27.848100662231445% Error: 72.15190124511719%
Iteration: 1400 Loss: 1.1254953145980835 Accuracy: 25.316455841064453% Error: 74.68354797363281%
Iteration: 1600 Loss: 1.9074203968048096 Accuracy: 25.316455841064453% Error: 74.68354797363281%
Iteration: 1800 Loss: 1.3322985172271729 Accuracy: 27.848100662231445% Error: 72.15190124511719%
Iteration: 2000 Loss: 1.3254060745239258 Accuracy: 25.316455841064453% Error: 74.68354797363281%
Iteration: 2200 Loss: 1.1631817817687988 Accuracy: 20.253164291381836% Error: 79.74683380126953%
Iteration: 2400 Loss: 1.2752320766448975 Accuracy: 20.253164291381836% Error: 79.74683380126953%
Iteration: 2600 Loss: 1.3860232830047607 Accuracy: 27.848100662231445% Error: 72.15190124511719%
Iteration: 2800 Loss: 1.2704166173934937 Accuracy: 20.253164291381836% Error: 79.74683380126953%
Iteration: 3000 Loss: 1.081123948097229 Accuracy: 25.316455841064453% Error: 74.68354797363281%
2.accuracy :
Train Doğruluk:
Got 180 / 200 with accuracy 90.00
Test Doğruluk:
Got 43 / 79 with accuracy 54.43```