I have batch the number of epochs to 300, the batch size to 128 and therefore, the number of iterations should be:
iterations = epochs * batchsize = 38400
However, I can see that in a forward pass the iterations has increased more than 128.
def train(dataset, name, model, optimizer, criterion, device, trainloader, validloader,
epochs, iters, save, paths, save_frequency=1, test=True, validate=True):
j = 0 # Iterations counter
model.train()
for epoch in range(1, epochs+1):
# Training
for i, (images, labels) in enumerate(trainloader):
j += 1
# Forward pass
# Backwad pass
# Calculate loss
# Calculate accuracy
stats = [epoch, epochs, j, iters, lss, acc]
print('\n Train: Epoch: [{}/{}] Iter: [{}/{}] Loss: {} Acc: {}%'.format(*stats))
# Validation
if validate:
for k, (images, labels) in enumerate(validloader):
# Forward pass
# Backwad pass
# Calculate loss
# Calculate accuracy
# Save model and delete previous if it is the best
stats = [epoch, epochs, j, iters, lss, acc]
print('\n Valid: Epoch: [{}/{}] Iter: [{}/{}] Loss: {} Acc: {}%'.format(*stats))
However, the result of this is printing:
Train: Epoch: [1/300] Iter: [352/38400] Loss: 1.564 Acc: 48.61%
Valid: Epoch: [1/300] Iter: [352/38400] Loss: 1.699 Acc: 34.28%
Train: Epoch: [2/300] Iter: [704/38400] Loss: 1.398 Acc: 44.44%
Valid: Epoch: [2/300] Iter: [704/38400] Loss: 1.973 Acc: 47.44%
Train: Epoch: [3/300] Iter: [1056/38400] Loss: 1.311 Acc: 56.94%
Valid: Epoch: [3/300] Iter: [1056/38400] Loss: 1.283 Acc: 58.06%
What am I missing?
Thanks in advance