output labels size: [32,2,10], where 32 is batch size, in this every image belongs to one of 10 subclasses from 2 classes. i have used Vgg and added one more classifier to it and used NLLLoss function but after trainiing the model for 50 epochs,my loss seems to be not decreasing much, it is around 3.5.
can anyone tell me which model should i use and the loss function.
below is my code:
loss_fn=CrossEntropyLoss()
loss_epoch_arr = []
max_epochs = 50

min_loss = 1000
batch_size = 64
loss_for_model={}

n_iters = np.ceil(9000/batch_size)
for lr in [0.01,0.01,0.05,0.009]:
    
    for w_d in [0.001,0.0001,0.0005,0.01]:
        
        opt = optim.Adam(model.parameters(), lr=lr,weight_decay=w_d,eps=0.1)    
        for epoch in range(max_epochs):
        
            for i, data in enumerate(train_loader, 0):
        
                images, labels = data
                images, labels = images.to(device), labels.to(device)
                        
                opt.zero_grad()
                out = custom_vgg.forward(images,model)
                out_classifier,out_classifier1 = out  
                labels1,labels2 = labels[:, 0], labels[:, 1] 
                
                targetnp=labels1.cpu().numpy()
                targetnp1 = labels2.cpu().numpy()
                idxs=np.where(targetnp>0)[1]
                idxs1=np.where(targetnp1>0)[1]
                new_targets=torch.LongTensor(idxs)
                new_targets1=torch.LongTensor(idxs1)
                new_targets = new_targets.to(device)
                new_targets1 = new_targets1.to(device)          
                loss_classifier = loss_fn(out_classifier, new_targets)
                loss_classifier1 = loss_fn(out_classifier1,new_targets1)
                loss = loss_classifier + loss_classifier1
                loss.backward()
                opt.step()
                
                if min_loss > loss.item():
                    min_loss = loss.item()
                    best_model = copy.deepcopy(model.state_dict())
                    print('Min loss %0.2f' % min_loss)
                
                if i % 100 == 0:
                    print('Iteration: %d/%d, Loss: %0.2f' % (i, n_iters, loss.item()))
                del images, labels, out, out_classifier, out_classifier1
                torch.cuda.empty_cache()                
            loss_epoch_arr.append(loss.item())
           loss_for_model["f{lr} + '_'+f{w_d}"] = min_loss
plt.plot(loss_epoch_arr)
plt.show()