ptrblck:

class MyDataset(Dataset):
    def __init__(self):
        self.data = torch.randn(200, 1)
        
    def __getitem__(self, idx):
        x = self.data[idx]
        return x

    def __len__(self):
        return len(self.data)

dataset = MyDataset()
loader = DataLoader(dataset, batch_size=256)

for data in loader:
    print(data.shape)



ok,but my concern is …


why my precision value is very bad for images less than the batch_size…although my prediction is almost correct


can i know how target is calculated in detail by printing it?(because target is changing for sample<256) have a look into target and prediction of copy of 10 classes
FOR 256 IMAGES
(‘target is’, tensor([ 0,  0,  0,  0,  0,  1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  3,  3,  3,
3,  3,  4,  4,  4,  4,  4,  5,  5,  5,  5,  5,  6,  6,  6,  6,  6,  7,
7,  7,  7,  7,  8,  8,  8,  8,  8,  9,  9,  9,  9,  9, 10, 10, 10, 10,
10,])
(‘pred is’, tensor([[  0,   0,   0,  44,   0,   1,   1, 315, 929,  58,   2,   2,   3, 496,
2,   3,   3,   3,   3,   3, 129,   4, 983,   4,   4, 377, 635,   6,
5, 961,   6,   6,   3,   6,   4,   7,   7,   8,   7,   8, 410,   7,
100, 144,   8,   9,   9,   9, 354,   9,  10,  10,  10,  42,  10,])
FOR 255 IMAGES
(‘target is’, tensor([ 1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  3,  3,  3,  3,  3,  4,  4,  4,
4,  4,  5,  5,  5,  5,  5,  6,  6,  6,  6,  6,  7,  7,  7,  7,  7,  8,
8,  8,  8,  8,  9,  9,  9,  9,  9, 10, 10, 10, 10, 10])
(‘pred is’, tensor([[  0,   0,   0,  44,   0,   1,   1, 315, 929,  58,   2,   2,   3, 496,
2,   3,   3,   3,   3,   3, 129,   4, 983,   4,   4, 377, 635,   6,
5, 961,   6,   6,   3,   6,   4,   7,   7,   8,   7,   8, 410,   7,
100, 144,   8,   9,   9,   9, 354,   9,  10,  10,  10,  42,  10])