Hi everybody,
I’ve been trying to debug what is happening but don’t know what’s wrong.
If you need more info let me know.
Regards!
epochs = 10
steps = 0
running_loss = 0
print_every = 5
for epoch in range(epochs):
for inputs, labels in train_loader:
steps += 1
    inputs, labels = inputs.to(device), labels.to(device)

    optimizer.zero_grad()
    logps = model.forward(inputs)
    loss = criterion(logps, labels)
    loss.backward()
    optimizer.step()

    running_loss += loss.item()
    
    if steps % print_every == 0:
        val_loss = 0
        accuracy = 0
        model.eval()
        
        with torch.no_grad():
            for inputs, labels in val_loader:
                inputs, labels = inputs.to(device), labels.to(device)
                logps = model.forward(inputs)
                batch_loss = criterion(logps, labels)
                
                val_loss += batch_loss.item()
                
                ps = torch.exp(logps)
                top_p, top_class = ps.topk(1, dim=1)
                equals = top_class == labels.view(*top_class.shape)
                accuracy += torch.mean(equals.tpye(torch.FloatTensor)).item()
        print('Epoch {}/{}'.format(epoch + 1, epochs))
        print('Train loss: {}'.format(running_loss/print_every))
        print('Val loss: {}'.format(val_loss/len(val_loader)))
        print('Val accuracy: {}'.format(accuracy/len(val_loader)))
        running_loss = 0
        model.train()