KFrank:

Note, the value of nBatch is not wired into your model. You can pass
in a batch of 250 ( [250, 244, 244] ), getting out a batch of 250
( [250, 15] ), and then, without changing the model pass in a batch
of 1 ( [1, 244, 244] --> [1, 15] ). (Also note, that if you want to apply
your model to a single sample, that sample has to be wrapped in
a batch of 1. That is, you can’t pass in [244, 244] ; you have to pass
in [1, 244, 244] ).
So, to repeat, your batch size of 250 does not appear in the code for
your model. And even though the last linear layer looks as if it outputs
a tensor of shape [15] ( out_features=15 ), because pytorch models
always work with batches, your model will output a tensor of shape
[nBatch, 15] , where nBatch is the size of the batch you passed
into your model.


inputs.shape & type  torch.Size([64, 1, 224, 224]) <class ‘torch.Tensor’>
labels.shape & type torch.Size([64, 15]) <class ‘torch.Tensor’>
imgindex & type (‘00001151_002.png’, ‘00000583_010.png’, ‘00000500_000.png’, ‘00000271_000.png’, …, ‘00000032_031.png’, ‘00000913_000.png’, ‘00001075_024.png’)
outputs, shape & type tensor([[-2.1863, -2.8136, -2.0755,  0.1303, -2.4541, -2.1647, -3.0948, -2.5282,
-1.9832, -2.4096, -2.6687, -2.7546, -2.1767, -2.6486, -3.0040],
[-2.3346, -1.7464, -1.3218, -0.2523, -1.8560, -0.8745, -1.6130, -1.5004,
-1.5930, -1.9782, -2.1910, -2.3470, -1.8963, -2.1992, -1.6291],
[-2.0328, -2.0936, -1.9872,  0.6333, -2.5061, -1.2418, -2.6371, -3.0564,
-2.0829, -2.0732, -2.0986, -2.5197, -2.8750, -2.4518, -2.9555],
…
[-2.5923, -2.6953, -1.5379,  0.2798, -2.7280, -1.5506, -2.4956, -1.8402,
-2.2393, -2.3018, -2.3598, -1.9540, -3.1476, -2.3570, -1.6612]],
device=‘cuda:0’, grad_fn=) torch.Size([64, 15]) <built-in method type of Tensor object at 0x7feedc76ec18>
Hi K. Frank,
The value of nBatch is being incorporated in the model. Currently I have set nBatch to 64.