As you can see in this code I printed out the number  of data coming in.
# parameters
training_epochs = 1
batch_size = 100

# dataset loader
data_loader = torch.utils.data.DataLoader(dataset=mnist_train,
                                          batch_size=batch_size,
                                          shuffle=True,
                                          drop_last=True)

for epoch in range(training_epochs):
    t0 = time.time()
    avg_cost = 0
    total_batch = len(data_loader)
    i = 1
    for X, Y in data_loader:
        print(i, end=" ")
        X = X.view(-1, 28 * 28).to(device)
        Y = Y.to(device)
        print(X.shape, Y.shape)

        optimizer.zero_grad()
        hypothesis = linear(X)
        cost = criterion(hypothesis, Y)
        cost.backward()
        optimizer.step()

        avg_cost += cost / total_batch
        i += 1
        t1 = time.time()

    print('Epoch:', '%04d' % (epoch + 1), 'cost =', '{:.5f}'.format(avg_cost), 'time : ',t1-t0)
print('Learning finished')

out
1 torch.Size([100, 784]) torch.Size([100])
2 torch.Size([100, 784]) torch.Size([100])
3 torch.Size([100, 784]) torch.Size([100])
4 torch.Size([100, 784]) torch.Size([100])
5 torch.Size([100, 784]) torch.Size([100])

...

598 torch.Size([100, 784]) torch.Size([100])
599 torch.Size([100, 784]) torch.Size([100])
600 torch.Size([100, 784]) torch.Size([100])
Epoch: 0001 cost = 0.33757 time :  28.640324354171753
Learning finished

seems it got 600 data in one iteration which batch size was 100.



 Nisan_Aryal:

If your batch size is 100 then you should be getting 100 data at one iteration.


this is so confusing