So I trained a FaceNet model and trained it on some popularly available datasets and then did a Post Training Static Quantization per tensor. When I pass the following two bright and dark images of same person, here are the tensor vector that I get
Quantized Model Bright Image
tensor([[ 0.0561, 0.0374, -0.0187, -0.0187, 0.0187, 0.1869, 0.0000, -0.1869,
-0.1308, -0.0935, 0.0374, -0.0374, 0.0187, -0.0187, -0.0748, -0.0935,
0.0561, 0.1122, 0.1495, 0.0561, -0.0935, -0.0187, -0.0748, -0.0935,
-0.0187, 0.0000, 0.0374, 0.1308, 0.0187, -0.1122, 0.1682, 0.0000,
0.1122, 0.1308, 0.0561, -0.0374, 0.0748, 0.0748, 0.0935, 0.0187,
0.1122, -0.0187, 0.0374, -0.0935, 0.0374, 0.0561, 0.1682, 0.0187,
0.1308, -0.0187, -0.1308, -0.1308, -0.1682, 0.1682, 0.0000, -0.0935,
-0.0935, 0.1682, -0.1122, 0.0000, 0.0561, 0.0000, 0.0935, 0.0561,
0.0561, 0.0748, -0.0561, 0.0187, 0.1308, 0.0187, -0.0187, 0.0935,
-0.0935, -0.1682, 0.0748, 0.0561, 0.0561, -0.1308, 0.1122, 0.0374,
0.1308, -0.0374, -0.1122, 0.0000, -0.0561, 0.0935, 0.1122, 0.0000,
0.0374, 0.0935, 0.0748, -0.0935, -0.0187, 0.0000, 0.1122, 0.0935,
0.0935, 0.0000, -0.0561, 0.0187, -0.0748, -0.0561, -0.0374, -0.0374,
0.0748, 0.0374, 0.1122, 0.1495, 0.0748, -0.1308, -0.0187, -0.0748,
-0.1495, 0.1308, -0.0374, 0.0561, -0.1122, -0.1495, 0.0935, 0.0374,
0.1122, -0.0187, -0.1682, -0.0374, -0.0374, 0.0748, -0.0374, -0.0935]])
Quantized Model Dark Image
tensor([[ 0.0000, 0.1400, -0.1400, -0.1400, 0.0000, 0.0000, 0.0000, 0.0000,
0.0000, -0.1400, 0.1400, 0.0000, -0.1400, -0.1400, -0.1400, 0.1400,
0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, -0.1400,
0.0000, 0.0000, 0.0000, 0.0000, -0.1400, -0.1400, 0.0000, 0.1400,
0.1400, 0.0000, 0.0000, 0.1400, 0.0000, 0.0000, 0.0000, 0.0000,
0.0000, 0.0000, 0.1400, -0.1400, 0.0000, 0.1400, 0.0000, -0.1400,
0.1400, 0.0000, 0.0000, -0.1400, 0.0000, 0.0000, 0.0000, 0.0000,
0.0000, 0.1400, 0.0000, 0.1400, 0.0000, 0.1400, 0.0000, 0.0000,
0.1400, 0.0000, -0.1400, 0.0000, 0.0000, -0.1400, -0.1400, 0.1400,
0.0000, 0.0000, 0.1400, 0.1400, -0.1400, 0.0000, 0.0000, 0.1400,
0.0000, 0.0000, -0.1400, 0.0000, 0.0000, 0.1400, 0.1400, 0.0000,
0.1400, 0.1400, 0.0000, -0.1400, 0.0000, 0.0000, 0.1400, 0.0000,
0.0000, 0.0000, -0.1400, 0.0000, 0.0000, 0.0000, -0.1400, -0.1400,
0.0000, 0.0000, 0.0000, 0.1400, 0.1400, 0.0000, 0.0000, -0.1400,
0.0000, 0.0000, 0.0000, 0.0000, -0.1400, 0.0000, 0.0000, 0.0000,
-0.1400, 0.1400, 0.0000, 0.0000, -0.1400, 0.0000, 0.0000, 0.1400]])
Float Model Bright Image
tensor([[ 0.0861, 0.0238, 0.0352, 0.0029, 0.0615, 0.1780, -0.0097, -0.1952,
-0.0903, -0.0788, 0.0177, -0.0488, 0.0668, 0.0072, -0.0666, -0.1656,
0.0768, 0.1084, 0.1639, 0.0932, -0.1083, -0.0076, -0.0793, -0.0751,
-0.0260, -0.0168, 0.0444, 0.1023, 0.0600, -0.0857, 0.1747, -0.0428,
0.0871, 0.1560, 0.0579, -0.0841, 0.0802, 0.1008, 0.1308, 0.0374,
0.1278, 0.0261, 0.0285, -0.0642, 0.0745, 0.0313, 0.1240, 0.0297,
0.0923, 0.0087, -0.1494, -0.1260, -0.1500, 0.1594, 0.0093, -0.0913,
-0.0484, 0.1636, -0.1199, -0.0250, 0.0465, -0.0563, 0.1218, 0.0532,
0.0462, 0.0253, 0.0085, 0.0233, 0.1121, 0.0526, 0.0266, 0.0940,
-0.0478, -0.1638, 0.0216, -0.0090, 0.1029, -0.1500, 0.0686, 0.0167,
0.1556, -0.0536, -0.1058, -0.0362, -0.0834, 0.0826, 0.0952, -0.0280,
0.0196, 0.0630, 0.0713, -0.0816, -0.0254, 0.0012, 0.0710, 0.0748,
0.0999, 0.0019, -0.0519, -0.0127, -0.0659, -0.0811, -0.0095, 0.0052,
0.1079, 0.0399, 0.0921, 0.1234, 0.0490, -0.0954, -0.0277, -0.0552,
-0.1533, 0.1452, -0.0379, -0.0052, -0.0722, -0.1557, 0.0774, 0.0535,
0.1366, -0.0835, -0.1754, -0.0819, -0.0021, 0.0779, 0.0258, -0.1439]])
Float Model Dark Image
tensor([[ 0.0185, 0.0525, -0.0193, 0.0219, -0.0442, 0.1609, 0.0900, -0.1719,
-0.1365, -0.0010, 0.0086, -0.0132, 0.0565, 0.0431, -0.1238, -0.1849,
0.0379, 0.0340, 0.1383, 0.0240, -0.0125, -0.0194, -0.0264, -0.0702,
-0.0551, 0.0823, -0.0586, 0.1484, 0.0281, -0.0548, 0.1889, -0.0370,
0.1532, 0.0888, 0.1133, -0.0229, -0.0050, 0.0519, 0.1196, -0.0315,
0.0500, -0.0685, -0.0457, -0.0130, -0.0261, 0.0653, 0.1504, 0.0326,
0.0794, -0.0984, -0.0833, -0.1707, -0.1208, 0.1833, -0.0721, -0.0145,
-0.1165, 0.1865, -0.0482, -0.0592, -0.0111, -0.0409, 0.0589, 0.1085,
-0.0397, 0.1304, -0.0190, 0.0610, 0.1475, 0.0917, 0.0584, 0.0731,
-0.1173, -0.1037, 0.1009, 0.0223, 0.0982, -0.1259, 0.0580, -0.0502,
0.0871, -0.1097, -0.0811, 0.0649, -0.0330, 0.0082, 0.0201, 0.0177,
-0.0395, 0.0232, -0.0185, -0.1652, 0.0592, -0.0826, 0.0182, 0.1457,
0.0332, -0.0251, 0.0230, 0.0367, -0.0267, 0.0105, -0.0303, 0.0189,
0.0193, 0.1108, 0.0677, 0.1400, 0.1273, -0.1494, 0.0124, 0.0039,
-0.1346, 0.1757, -0.1120, 0.0749, -0.1457, -0.1344, 0.1237, -0.0492,
0.1096, -0.0871, -0.1244, -0.0005, 0.0183, -0.0082, -0.0711, -0.0827]])
As can seen that the output tensor for float model and quantized model on bright image have different values in them. However the output tensor for quantized model on dark image have lots of zeros in them which doesn’t appear in the output tensor of floating model on dark image.
I would like to know why this is happening