Datasets:
File size: 106,372 Bytes
94a37e3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 | [
{
"type": "text",
"text": "CONDITIONAL POSITIONAL ENCODINGS FOR VISION TRANSFORMERS ",
"text_level": 1,
"bbox": [
176,
98,
820,
145
],
"page_idx": 0
},
{
"type": "text",
"text": "Xiangxiang $\\mathbf { C h u ^ { 1 } }$ , Zhi Tian1, Bo Zhang1, Xinlong Wang2, Chunhua Shen3∗ 1 Meituan Inc. 2 Beijing Academy of AI 3 Zhejiang University, China {chuxiangxiang, tianzhi02, zhangbo97}@meituan.com, xinlong.wang96@gmail.com, chunhua@me.com ",
"bbox": [
183,
169,
738,
227
],
"page_idx": 0
},
{
"type": "text",
"text": "ABSTRACT ",
"text_level": 1,
"bbox": [
454,
263,
544,
279
],
"page_idx": 0
},
{
"type": "text",
"text": "We propose a conditional positional encoding (CPE) scheme for vision Transformers (Dosovitskiy et al., 2021; Touvron et al., 2020). Unlike previous fixed or learnable positional encodings that are predefined and independent of input tokens, CPE is dynamically generated and conditioned on the local neighborhood of the input tokens. As a result, CPE can easily generalize to the input sequences that are longer than what the model has ever seen during the training. Besides, CPE can keep the desired translation equivalence in vision tasks, resulting in improved performance. We implement CPE with a simple Position Encoding Generator (PEG) to get seamlessly incorporated into the current Transformer framework. Built on PEG, we present Conditional Position encoding Vision Transformer (CPVT). We demonstrate that CPVT has visually similar attention maps compared to those with learned positional encodings and delivers outperforming results. Our Code is available at: https://git.io/CPVT. ",
"bbox": [
233,
296,
764,
476
],
"page_idx": 0
},
{
"type": "text",
"text": "1 INTRODUCTION ",
"text_level": 1,
"bbox": [
176,
505,
334,
521
],
"page_idx": 0
},
{
"type": "text",
"text": "Recently, Transformers (Vaswani et al., 2017) have been viewed as a strong alternative to Convolutional Neural Networks (CNNs) in visual recognition tasks such as classification (Dosovitskiy et al., 2021) and detection (Carion et al., 2020; Zhu et al., 2021). Unlike the convolution operation in CNNs, which has a limited receptive field, the self-attention mechanism in the Transformers can capture the long-distance information and dynamically adapt the receptive field according to the image content. Consequently, Transformers are considered more flexible and powerful than CNNs, being promising to achieve more progress in visual recognition. ",
"bbox": [
174,
537,
825,
635
],
"page_idx": 0
},
{
"type": "text",
"text": "However, the self-attention operation in Transformers is permutation-invariant, which discards the order of the tokens in an input sequence. To mitigate this issue, previous works (Vaswani et al., 2017; Dosovitskiy et al., 2021) add the absolute positional encodings to each input token (see Figure 1a), which enables order-awareness. The positional encoding can either be learnable or fixed with sinusoidal functions of different frequencies. Despite being effective, these positional encodings seriously harm the flexibility of the Transformers, hampering their broader applications. Taking the learnable version as an example, the encodings are often a vector of equal length to the input sequence, which are jointly updated with the network weights during training. As a result, the length and the value of the positional encodings are fixed once trained. During testing, it causes difficulties of handling the sequences longer than the ones in the training data. ",
"bbox": [
174,
642,
825,
780
],
"page_idx": 0
},
{
"type": "text",
"text": "The inability to adapt to longer input sequences during testing greatly limits the range of generalization. For instance, in vision tasks like object detection, we expect the model can be applied to the images of any size during inference, which might be much larger than the training images. A possible remedy is to use bicubic interpolation to upsample the positional encodings to the target length, but it degrades the performance without fine-tuning as later shown in our experiments. For vision in general, we expect that the models be translation-equivariant. For example, the output feature maps of CNNs shift accordingly as the target objects are moved in the input images. However, the absolute positional encoding scheme might break the translation equivalence because it adds unique positional encodings to each token (or each image patch). One may overcome the issue with relative positional encodings as in (Shaw et al., 2018). However, relative positional encodings not only come with extra computational costs, but also require modifying the implementation of the standard Transformers. Last but not least, the relative positional encodings cannot work equally well as the absolute ones, because the image recognition task still requires absolute position information (Islam et al., 2020), which the relative positional encodings fail to provide. ",
"bbox": [
174,
787,
823,
898
],
"page_idx": 0
},
{
"type": "image",
"img_path": "images/0c4b2513e8c89ba2d4113b63f9bdb7b99d31471e828098a2ee34f19b9c920289.jpg",
"image_caption": [
"Figure 1. Vision Transformers: (a) ViT (Dosovitskiy et al., 2021) with explicit 1D learnable positional encodings (PE) (b) CPVT with conditional positional encoding from the proposed Position Encoding Generator (PEG) plugin, which is the default choice. (c) CPVT-GAP without class token (cls), but with global average pooling (GAP) over all items in the sequence. Note that GAP is a bonus version which has boosted performance. "
],
"image_footnote": [],
"bbox": [
202,
101,
772,
323
],
"page_idx": 1
},
{
"type": "text",
"text": "",
"bbox": [
174,
435,
825,
520
],
"page_idx": 1
},
{
"type": "text",
"text": "In this work, we advocate a novel positional encoding (PE) scheme to incorporate the position information into Transformers. Unlike the predefined and input-agnostic positional encodings used in previous works (Dosovitskiy et al., 2021; Vaswani et al., 2017; Shaw et al., 2018), the proposed PE is dynamically generated and conditioned on the local neighborhood of input tokens. Thus, our positional encodings can change along with the input size and try to keep translation equivalence. We demonstrate that the vision transformers (Dosovitskiy et al., 2021; Touvron et al., 2020) with our new PE (i.e. CPVT, see Figure 1c) achieve even better performance. We summarize our contributions as, • We propose a novel positional encoding (PE) scheme, termed conditional position encodings (CPE). CPE is dynamically generated with Positional Encoding Generators (PEG) and can be effortlessly implemented by the modern deep learning frameworks (Paszke et al., 2019; Abadi et al., 2016; Chen et al., 2015), requiring no changes to the current Transformer APIs. Through an in-depth analysis and thorough experimentations, we unveil that this design affords both absolute and relative encoding yet it goes above and beyond. ",
"bbox": [
173,
526,
825,
625
],
"page_idx": 1
},
{
"type": "text",
"text": "",
"bbox": [
218,
647,
825,
731
],
"page_idx": 1
},
{
"type": "text",
"text": "• As opposed to widely-used absolute positional encodings, CPE can provide a kind of stronger explicit bias towards the translation equivalence which is important to improve the performance of Transformers. ",
"bbox": [
218,
748,
823,
790
],
"page_idx": 1
},
{
"type": "text",
"text": "• Built on CPE, we propose Conditional Position encoding Vision Transformer (CPVT). It achieves better performance than previous vison transformers (Dosovitskiy et al., 2021; Touvron et al., 2020). ",
"bbox": [
218,
808,
825,
849
],
"page_idx": 1
},
{
"type": "text",
"text": "• CPE can well generalize to arbitrary input resolutions, which are required in many important downstream tasks such as segmentation and detection. Through experiments we show that CPE can boost the segmentation and detection performance for pyramid transformers like (Wang et al., 2021) by a clear margin. ",
"bbox": [
220,
867,
823,
924
],
"page_idx": 1
},
{
"type": "text",
"text": "2 RELATED WORK ",
"text_level": 1,
"bbox": [
176,
102,
344,
117
],
"page_idx": 2
},
{
"type": "text",
"text": "Since self-attention itself is permutation-equivariant (see A), positional encodings are commonly employed to incorporate the order of sequences (Vaswani et al., 2017). The positional encodings can either be fixed or learnable, while either being absolute or relative. Vision transformers follow the same fashion to imbue the network with positional information. ",
"bbox": [
174,
133,
823,
189
],
"page_idx": 2
},
{
"type": "text",
"text": "Absolute Positional Encoding. The absolute positional encoding is the most widely used. In the original transformer (Vaswani et al., 2017), the encodings are generated with the sinusoidal functions of different frequencies and then they are added to the inputs. Alternatively, the positional encodings can be learnable, where they are implemented with a fixed-dimension matrix/tensor and jointly updated with the model’s parameters with SGD. ",
"bbox": [
174,
204,
825,
273
],
"page_idx": 2
},
{
"type": "text",
"text": "Relative Positional Encoding. The relative position encoding (Shaw et al., 2018) considers distances between the tokens in the input sequence. Compared to the absolute ones, the relative positional encodings can be translation-equivariant and can naturally handle the sequences longer than the longest sequences during training (i.e., being inductive). A 2-D relative position encoding is proposed for image classification in (Bello et al., 2019), showing superiority to 2D sinusoidal embeddings. The relative positional encoding is further improved in XLNet (Yang et al., 2019b) and DeBERTa (He et al., 2020), showing better performance. ",
"bbox": [
174,
290,
823,
387
],
"page_idx": 2
},
{
"type": "text",
"text": "Other forms. Complex-value embeddings (Wang et al., 2019) are an extension to model global absolute encodings and show improvement. RoFormer (Su et al., 2021) utilizes a rotary position embedding to encode both absolute and relative position information for text classification. FLOATER (Liu et al., 2020) proposes a novel continuous dynamical model to capture position encodings. It is not limited by the maximum sequence length during training, meanwhile being parameter-efficient. ",
"bbox": [
174,
402,
823,
473
],
"page_idx": 2
},
{
"type": "text",
"text": "Similar designs to CPE. Convolutions are used to model local relations in ASR and machine translation (Gulati et al., 2020; Mohamed et al., 2019; Yang et al., 2019a; Yu et al., 2018). However, they are mainly limited to 1D signals. We instead process 2D vision images. ",
"bbox": [
176,
487,
823,
530
],
"page_idx": 2
},
{
"type": "text",
"text": "3 VISION TRANSFORMER WITH CONDITIONAL POSITION ENCODINGS ",
"text_level": 1,
"bbox": [
173,
549,
767,
566
],
"page_idx": 2
},
{
"type": "text",
"text": "3.1 MOTIVATION ",
"text_level": 1,
"bbox": [
174,
580,
305,
595
],
"page_idx": 2
},
{
"type": "text",
"text": "In vision transformers, an input image of size $H \\times W$ is split into patches with size $S \\times S$ , the number of patches is $\\begin{array} { r } { \\dot { N } = \\frac { H \\dot { W } \\mathbb { 1 } } { S ^ { 2 } } } \\end{array}$ . The patches are added with the same number of learnable absolute positional encoding vectors. In this work, we argue that the positional encodings used here have two issues. First, it prevents the model from handling the sequences longer than the learnable PE. Second, it makes the model not translation-equivariant because a unique positional encoding vector is added to every one patch. The translation equivalence plays an important role in classification because we hope the networks’ responses changes accordingly as the object moves in the image. ",
"bbox": [
174,
607,
825,
705
],
"page_idx": 2
},
{
"type": "text",
"text": "One may note that the first issue can be remedied by removing the positional encodings since except for the positional encodings, all other components (e.g., MHSA and FFN) of the vision transformer can directly be applied to longer sequences. However, this solution severely deteriorates the performance. This is understandable because the order of the input sequence is an important clue and the model has no way to extract the order without the positional encodings. The experiment results on ImageNet are shown in Table 1. By removing the positional encodings, DeiT-tiny’s performance on ImageNet dramatically degrades from $7 2 . 2 \\%$ to $6 8 . 2 \\%$ . ",
"bbox": [
174,
712,
825,
809
],
"page_idx": 2
},
{
"type": "text",
"text": "Second, in DeiT (Touvron et al., 2020), they show that we can interpolate the position encodings to make them have the same length of the longer sequences. However, this method requires finetuning the model a few more epochs, otherwise the performance will remarkably drop, as shown in Table 1. This goes contrary to what we would expect. With the higher-resolution inputs, we often expect a remarkable performance improvement without any fine-tuning. Finally, the relative position encodings (Shaw et al., 2018; Bello et al., 2019) can cope with both the aforementioned issues. However, the relative positional encoding cannot provide absolute position information, which is also important to the classification performance (Islam et al., 2020). As shown in Table 1, the model with relative position encodings has inferior performance ( $7 0 . 5 \\%$ vs. $7 2 . 2 \\%$ ). ",
"bbox": [
174,
816,
825,
900
],
"page_idx": 2
},
{
"type": "table",
"img_path": "images/777658109f20f506564abf78728d41e9469175d72aa4de071291272306f43b7e.jpg",
"table_caption": [
"Table 1. Comparison of various positional encoding (PE) strategies tested on ImageNet validation set in terms of the top-1 accuracy. Removing the positional encodings greatly damages the performance. The relative positional encodings have inferior performance to the absolute ones "
],
"table_footnote": [],
"table_body": "<table><tr><td>Model</td><td>Encoding</td><td>Top-1@224(%)</td><td>Top-1@384(%)</td></tr><tr><td>DeiT-tiny (Touvron et al., 2020)</td><td>X</td><td>68.2</td><td>68.6</td></tr><tr><td>DeiT-tiny (Touvron et al., 2020)</td><td>learnable</td><td>72.2</td><td>71.2</td></tr><tr><td>DeiT-tiny (Touvron et al., 2020)</td><td>sin-cos</td><td>72.3</td><td>70.8</td></tr><tr><td>DeiT-tiny</td><td>2D RPE (Shaw et al., 2018)</td><td>70.5</td><td>69.8</td></tr></table>",
"bbox": [
189,
161,
808,
234
],
"page_idx": 3
},
{
"type": "text",
"text": "",
"bbox": [
176,
247,
825,
290
],
"page_idx": 3
},
{
"type": "text",
"text": "3.2 CONDITIONAL POSITIONAL ENCODINGS ",
"text_level": 1,
"bbox": [
176,
306,
495,
320
],
"page_idx": 3
},
{
"type": "text",
"text": "We argue that a successful positional encoding for vision tasks should meet these requirements, ",
"bbox": [
181,
332,
797,
347
],
"page_idx": 3
},
{
"type": "text",
"text": "(1) Making the input sequence permutation-variant and providing stronger explicit bias towards translation-equivariance. \n(2) Being inductive and able to handle the sequences longer than the ones during training. \n(3) Having the ability to provide the absolute position to a certain degree. This is important to the performance as shown in (Islam et al., 2020). ",
"bbox": [
205,
358,
825,
438
],
"page_idx": 3
},
{
"type": "text",
"text": "In this work, we find that characterizing the local relationship by positional encodings is sufficient to meet all of the above. First, it is permutation-variant because the permutation of input sequences also affects the order in some local neighborhoods. However, translation of an object in an input image does not change the order in its local neighborhood, i.e., translation-equivariant (see Section A). Second, the model can easily generalize to longer sequences since only the local neighborhoods of a token are involved. Besides, if the absolute position of any input token is known, the absolute position of all the other tokens can be inferred by the mutual relation between input tokens. We will show that the tokens on the borders can be aware of their absolute positions due to the commonly-used zero paddings. ",
"bbox": [
173,
449,
825,
574
],
"page_idx": 3
},
{
"type": "text",
"text": "Therefore, we propose positional encoding generators (PEG) to dynamically produce the positional encodings conditioned on the local neighborhood of an input token. ",
"bbox": [
173,
582,
343,
691
],
"page_idx": 3
},
{
"type": "text",
"text": "Positional Encoding Generator. PEG is illustrated in Figure 2. To condition on the local neighbors, we first ",
"bbox": [
173,
699,
346,
770
],
"page_idx": 3
},
{
"type": "image",
"img_path": "images/e12ed07e330e1cbad3fc807996e87af006eec2275384ddc7e13bc09ba9a2aac7.jpg",
"image_caption": [
"Figure 2. Schematic illustration of Positional Encoding Generator (PEG). Note $d$ is the embedding size, $N$ is the number of tokens. "
],
"image_footnote": [],
"bbox": [
364,
582,
820,
703
],
"page_idx": 3
},
{
"type": "text",
"text": "reshape the flattened input sequence $X \\in \\mathbb { R } ^ { B \\times N \\times C }$ of DeiT back to $X ^ { \\prime } \\in \\mathbb { R } ^ { B \\times H \\times W \\times C }$ in the 2-D image space. Then, a function (denoted by $\\mathcal { F }$ in Figure 2) is repeatedly applied to the local patch in $X ^ { \\prime }$ to produce the conditional positional encodings $E ^ { \\tilde { B } \\times H \\times \\tilde { W } \\times C }$ . PEG can be efficiently implemented with a 2-D convolution with kernel zero paddings here are important to make the mo $k$ l $( k \\geq 3 )$ and re of $\\frac { k - 1 } { 2 }$ zero paddings. Note tabsolute positions, and thecan $\\mathcal { F }$ be of various forms such as various types of convolutions and many others. ",
"bbox": [
173,
768,
825,
853
],
"page_idx": 3
},
{
"type": "text",
"text": "3.3 CONDITIONAL POSITIONAL ENCODING VISION TRANSFORMERS ",
"text_level": 1,
"bbox": [
176,
869,
661,
883
],
"page_idx": 3
},
{
"type": "text",
"text": "Built on the conditional positional encodings, we propose our Conditional Positional Encoding Vision Transformers (CPVT). Except that our positional encodings are conditional, we exactly follow ",
"bbox": [
174,
895,
818,
924
],
"page_idx": 3
},
{
"type": "text",
"text": "ViT and DeiT to design our vision transformers and we also have three sizes CPVT-Ti, CPVT-S and CPVT-B. Similar to the original positional encodings in DeiT, the conditional positional encodings are also added to the input sequence, as shown in Figure 1 (b). In CPVT, the position where PEG is applied is also important to the performance, which will be studied in the experiments. ",
"bbox": [
174,
103,
823,
159
],
"page_idx": 4
},
{
"type": "text",
"text": "In addition, both DeiT and ViT utilize an extra learnable class token to perform classification (i.e., cls token shown in Figure 1 (a) and (b)). By design, the class token is not translation-invariant, although it can learn to be so. A simple alternative is to directly replace it with a global average pooling (GAP), which is inherently translation-invariant, resulting in our CVPT-GAP. Together with CPE, CVPT-GAP achieves much better image classification performance. ",
"bbox": [
174,
166,
825,
236
],
"page_idx": 4
},
{
"type": "text",
"text": "4 EXPERIMENTS ",
"text_level": 1,
"bbox": [
176,
258,
326,
275
],
"page_idx": 4
},
{
"type": "text",
"text": "4.1 SETUP ",
"text_level": 1,
"bbox": [
174,
291,
261,
306
],
"page_idx": 4
},
{
"type": "text",
"text": "Datasets. Following DeiT (Touvron et al., 2020), we use ILSVRC-2012 ImageNet dataset (Deng et al., 2009) with 1K classes and 1.3M images to train all our models. We report the results on the validation set with 50K images. Unlike ViT (Dosovitskiy et al., 2021), we do not use the much larger undisclosed JFT-300M dataset (Sun et al., 2017). ",
"bbox": [
174,
318,
825,
375
],
"page_idx": 4
},
{
"type": "text",
"text": "Model variants. We have three models with various sizes to adapt to various computing scenarios. The detailed settings are shown in Table 9 (see B.1). All experiments in this paper are performed on Tesla V100 machines. Training the tiny model for 300 epochs takes about 1.3 days on a single node with 8 V100 GPU cards. CPVT-S and CPVT-B take about 1.6 and 2.5 days, respectively. ",
"bbox": [
174,
381,
823,
436
],
"page_idx": 4
},
{
"type": "text",
"text": "Training details All the models (except for CPVT-B) are trained for 300 epochs with a global batch size of 2048 on Tesla V100 machines using AdamW optimizer (Loshchilov & Hutter, 2019). We do not tune the hyper-parameters and strictly comply with the settings in DeiT (Touvron et al., 2020). The learning rate is scaled with this formula $l r _ { \\mathrm { s c a l e } } = 0 . 0 0 0 5 { \\cdot } \\mathrm { B a t c h S i z e } _ { \\mathrm { g l o b a l } } / { \\scriptstyle 5 1 2 }$ . The detailed hyperparameters are in the B.2. ",
"bbox": [
174,
444,
825,
513
],
"page_idx": 4
},
{
"type": "text",
"text": "4.2 GENERALIZATION TO HIGHER RESOLUTIONS ",
"text_level": 1,
"bbox": [
174,
534,
527,
547
],
"page_idx": 4
},
{
"type": "text",
"text": "As mentioned before, our proposed PEG can directly generalize to larger image sizes without any fine-tuning. We confirm this here by evaluating the models trained with $2 2 4 \\times 2 2 4$ images on the $3 8 4 \\times 3 8 4$ , $4 4 8 \\times 4 4 8$ , $5 1 2 \\times 5 1 2$ images, respectively. The results are shown in Table 2. With the $3 8 4 \\times 3 8 4$ input images, the DeiT-tiny with learnable positional encodings degrades from $7 2 . 2 \\%$ to $7 1 . 2 \\%$ . When equipped with sine encoding, the tiny model degrades from $7 2 . 2 \\%$ to $7 0 . 8 \\%$ . In constrat, our CPVT model with the proposed PEG can directly process the larger input images, and CPVT-Ti’s performance is boosted from $7 3 . 4 \\%$ to $7 4 . 2 \\%$ when applied to $3 8 4 \\times 3 8 4$ images. Our CPVT-Ti outperforms DeiT-tiny by $3 . 0 \\%$ . This gap continues to increase as the input resolution enlarges. ",
"bbox": [
174,
559,
825,
685
],
"page_idx": 4
},
{
"type": "table",
"img_path": "images/ab1cbd1190803aa7fd6c2b7ced714aed46988bc72d1faf1b2b651896176f78f0.jpg",
"table_caption": [
"Table 2. Direct evaluation on other resolutions without fine-tuning. The models are trained on $2 2 4 \\times 2 2 4$ . A simple PEG of a single layer of $3 \\times 3$ depth-wise convolution is used here "
],
"table_footnote": [
"‡: Insert one PEG each after the first encoder till the fifth encoder "
],
"table_body": "<table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>Params</td><td rowspan=1 colspan=1>160(%)</td><td rowspan=1 colspan=1>224(%)</td><td rowspan=1 colspan=1>384(%)</td><td rowspan=1 colspan=1>448(%)</td><td rowspan=1 colspan=1>512(%)</td></tr><tr><td rowspan=1 colspan=1>DeiT-tinyDeiT-tiny (sin)DeiT-tiny (no pos)CPVT-TiCPVT-Ti ‡</td><td rowspan=1 colspan=1>6M6M6M6M6M</td><td rowspan=1 colspan=1>65.665.262.166.8(+1.2)67.7 (+2.1)</td><td rowspan=1 colspan=1>72.272.368.272.4(+0.2)73.4(+1.2)</td><td rowspan=1 colspan=1>71.270.868.673.2(+2.0)74.2(+3.0)</td><td rowspan=1 colspan=1>68.868.268.471.8(+3.0)72.6(+3.8)</td><td rowspan=1 colspan=1>65.965.165.070.3(+4.4)70.8(+4.9)</td></tr><tr><td rowspan=1 colspan=1>DeiT-smallCPVT-S</td><td rowspan=1 colspan=1>22M22M</td><td rowspan=1 colspan=1>75.676.1(+0.5)</td><td rowspan=1 colspan=1>79.979.9</td><td rowspan=1 colspan=1>78.180.4(+1.5)</td><td rowspan=1 colspan=1>75.978.6(+2.7)</td><td rowspan=1 colspan=1>72.676.8(+4.2)</td></tr><tr><td rowspan=1 colspan=1>DeiT-baseCPVT-B</td><td rowspan=1 colspan=1>86M86M</td><td rowspan=1 colspan=1>79.180.5(+1.4)</td><td rowspan=1 colspan=1>81.881.9(+0.1)</td><td rowspan=1 colspan=1>79.782.3(+2.6)</td><td rowspan=1 colspan=1>79.882.4(+2.6)</td><td rowspan=1 colspan=1>78.281.0(+2.8)</td></tr></table>",
"bbox": [
205,
746,
794,
891
],
"page_idx": 4
},
{
"type": "text",
"text": "4.3 CPVT WITH GLOBAL AVERAGE POOLING ",
"text_level": 1,
"bbox": [
176,
103,
504,
117
],
"page_idx": 5
},
{
"type": "text",
"text": "By design, the proposed PEG is translation-equivariant (ignore paddings). Thus, if we further use the translation-invariant global average pooling (GAP) instead of the cls token before the final classification layer of CPVT. CPVT can be translation-invariant, which should be beneficial to the ImageNet classification task. Note the using GAP here results in even less computation complexity because we do not need to compute the attention interaction between the class token and the image patches. As shown in Table 3, using GAP here can boost CPVT by more than $1 \\%$ . For example, equipping CPVT-Ti with GAP obtains $7 4 . 9 \\%$ top-1 accuracy on the ImageNet validation dataset, which outperforms DeiT-tiny by a large margin $( + 2 . 7 \\% )$ . Moreover, it even exceeds DeiT-tiny model with distillation $( 7 4 . 5 \\% )$ . In contrast, DeiT with GAP cannot gain so much improvement (only $0 . 4 \\%$ as shown in Table 3) because the original learnable absolute PE is not translation-equivariant and thus GAP with the PE is not translation-invariant. Given the superior performance, we hope our model can be a strong PE alternative in vision transformers. ",
"bbox": [
173,
128,
825,
296
],
"page_idx": 5
},
{
"type": "table",
"img_path": "images/3dc1c296f9299bd138b8b334ecbaa6aa75e5f72905c2e70be90bfa6573173918.jpg",
"table_caption": [
"Table 3. Performance comparison of Class Token (CLT) and global average pooling (GAP) on ImageNet. CPVT’s can be further boosted with GAP "
],
"table_footnote": [
"‡: Insert one PEG each after the first encoder till the fifth encoder "
],
"table_body": "<table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>Head</td><td rowspan=1 colspan=1>Params</td><td rowspan=1 colspan=1>Top-1 Acc(%)</td><td rowspan=1 colspan=1>Top-5 Acc(%)</td></tr><tr><td rowspan=1 colspan=1>DeiT-tiny (Touvron et al., 2020)DeiT-tinyCPVT-Ti tCPVT-Ti t</td><td rowspan=1 colspan=1>CLTGAPCLTGAP</td><td rowspan=1 colspan=1>6M6M6M6M</td><td rowspan=1 colspan=1>72.272.673.474.9</td><td rowspan=1 colspan=1>91.091.291.892.6</td></tr><tr><td rowspan=3 colspan=1>DeiT-small (Touvron et al.,2020)DeiT-smallCPVT-S ‡CPVT-S t</td><td rowspan=1 colspan=1>CLTGAP</td><td rowspan=2 colspan=1>22M22M23M</td><td rowspan=2 colspan=1>79.980.280.5</td><td rowspan=3 colspan=1>95.095.295.295.7</td></tr><tr><td rowspan=1 colspan=1>CLT</td></tr><tr><td rowspan=1 colspan=1>GAP</td><td rowspan=1 colspan=1>23M</td><td rowspan=1 colspan=1>81.5</td></tr></table>",
"bbox": [
253,
354,
745,
501
],
"page_idx": 5
},
{
"type": "text",
"text": "4.4 COMPLEXITY OF PEG ",
"text_level": 1,
"bbox": [
174,
542,
369,
558
],
"page_idx": 5
},
{
"type": "text",
"text": "Few Parameters. Given the model dimension $d$ , the extra number of parameters introduced by PEG is $d \\times l \\times k ^ { 2 }$ if we choose $l$ depth-wise convolutions with kernel $k$ . If we use $l$ separable convolutions, this value becomes $l ( d ^ { 2 } + k ^ { 2 } d )$ . When $k = 3$ and $l = 1$ , CPVT-Ti $d = 1 9 2 ,$ ) brings about 1, 728 parameters. Note that DeiT-tiny utilizes learnable position encodings with $1 9 2 \\times 1 4 \\times 1 4 = 3 7 6 3 2$ parameters. Therefore, CPVT-Ti has 35, 904 fewer number of parameters than DeiT-tiny. Even using 4 layers of separable convolutions, CPVT-Ti introduces only $3 8 9 5 2 - 3 7 6 3 2 = 9 6 0$ more parameters, which is negelectable compared to the $5 . 7 \\mathbf { M }$ model parameters of DeiT-tiny. ",
"bbox": [
173,
575,
825,
674
],
"page_idx": 5
},
{
"type": "text",
"text": "FLOPs. As for FLOPs, $l$ layers of $k \\times k$ depth-wise convolutions possesses $1 4 \\times 1 4 \\times d \\times l \\times k ^ { 2 }$ FLOPS. Taking the tiny model for example, it involves $1 9 6 \\times 1 9 2 \\times 9 = 0 . 3 4 M$ FLOPS for the simple case $k = 3$ and $l = 1$ , which is neglectable because the model has 2.1G FLOPs in total. ",
"bbox": [
174,
685,
825,
728
],
"page_idx": 5
},
{
"type": "text",
"text": "4.5 PERFORMANCE COMPARISON ",
"text_level": 1,
"bbox": [
176,
744,
419,
758
],
"page_idx": 5
},
{
"type": "text",
"text": "We evaluate the performance of CPVT models on the ImageNet validation dataset and report the results in Table 4. Compared with DeiT, CPVT models have much better top-1 accuracy with similar throughputs. Our models can enjoy performance improvement when inputs are upscaled without fine-tuning, while DeiT degrades as discussed in Table 2, see also Figure 3 for a clear comparison. Noticeably, Our model with GAP marked a new state-of-the-art for vision Transformers. ",
"bbox": [
174,
770,
483,
922
],
"page_idx": 5
},
{
"type": "image",
"img_path": "images/c53aeceb62b3945f870e2289f3bd7dc81107062bd6e3b4e704ad90e2320543d6.jpg",
"image_caption": [
"Figure 3. Comparison of CPVT and DeiT models under various configurations. Note CPVT $@ 3 8 4$ has improved performance. More PEGs can result in better performance. CPVT-GAP is the best. "
],
"image_footnote": [],
"bbox": [
504,
733,
813,
869
],
"page_idx": 5
},
{
"type": "table",
"img_path": "images/d3a58c8cebdf84cdf2503d3f0b23c663985798b43d4e76a1b1f0608cbe091018.jpg",
"table_caption": [
"Table 4. Comparison with ConvNets and Transformers on ImageNet and ImageNet Real (Beyer et al., 2020). CPVT have much better performance compared with prior Transformers "
],
"table_footnote": [
"?: Measured in img/s on a 16GB V100 GPU as in (Touvron et al., 2020). ‡: Insert one PEG each after the first encoder till the fifth encoder ⚗ : trained with hard distillation using RegNetY-160 as the teacher. "
],
"table_body": "<table><tr><td rowspan=1 colspan=1>Models</td><td rowspan=1 colspan=2>Params(M) Input</td><td rowspan=1 colspan=1>Input</td><td rowspan=1 colspan=2>|throughput*</td><td rowspan=1 colspan=1>ImNettop-1 %</td><td rowspan=1 colspan=1>Realtop-1 %</td></tr><tr><td rowspan=7 colspan=1>ResNet-50 (He et al., 2016)ResNet-101 (He et al., 2016)ResNet-152 (He et al.,2016)RegNetY-4GF (Radosavovic et al.,2020)EfficientNet-BO (Tan &Le,2019)EfficientNet-B1 (Tan&Le,2019)EfficientNet-B2 (Tan &Le,2019)EfficientNet-B3(Tan&Le,2019)EfficientNet-B4 (Tan& Le,2019)</td><td rowspan=3 colspan=2>25456021</td><td rowspan=1 colspan=1>2242</td><td rowspan=1 colspan=2>1226.1</td><td rowspan=1 colspan=1>76.2</td><td rowspan=1 colspan=1>82.5</td></tr><tr><td rowspan=2 colspan=1>224222422242</td><td rowspan=2 colspan=2>753.6526.41156.7</td><td rowspan=1 colspan=1>753.6</td><td rowspan=1 colspan=1>77.4</td><td rowspan=1 colspan=1>83.7</td></tr><tr><td rowspan=1 colspan=1>78.380.0</td><td rowspan=1 colspan=1>84.186.4</td></tr><tr><td rowspan=4 colspan=2>5891219</td><td rowspan=1 colspan=1>5</td><td rowspan=1 colspan=1>2242</td><td rowspan=1 colspan=2>2694.3</td><td rowspan=1 colspan=1>77.1</td><td rowspan=1 colspan=1>83.5</td></tr><tr><td rowspan=1 colspan=1>240²</td><td rowspan=2 colspan=2>1662.51255.7732.1</td><td rowspan=1 colspan=1>79.1</td><td rowspan=1 colspan=1>84.9</td></tr><tr><td rowspan=1 colspan=1>260²3002</td><td rowspan=1 colspan=1>80.181.6</td><td rowspan=1 colspan=1>85.986.8</td></tr><tr><td rowspan=1 colspan=1>3802</td><td rowspan=1 colspan=2>349.4</td><td rowspan=1 colspan=1>82.9</td><td rowspan=1 colspan=1>88.0</td></tr><tr><td rowspan=2 colspan=1>ViT-B/16 (Dosovitskiy et al., 2021)ViT-L/16</td><td rowspan=2 colspan=2>86307</td><td rowspan=1 colspan=1>3842</td><td rowspan=2 colspan=2>85.927.3</td><td rowspan=2 colspan=1>77.976.5</td><td rowspan=2 colspan=1>11</td></tr><tr><td rowspan=1 colspan=1>3842</td></tr><tr><td rowspan=1 colspan=1>DeiT-tiny w/o PE (Touvron et al., 2020)DeiT-tiny (Touvron et al.,2020)DeiT-tiny (sine)CPVT-Ti tCPVT-Ti-GAP‡</td><td rowspan=1 colspan=2>66666</td><td rowspan=1 colspan=1>224222422242224²2242</td><td rowspan=1 colspan=2>2536.52536.52536.52500.72520.1</td><td rowspan=1 colspan=1>68.272.272.373.474.9</td><td rowspan=1 colspan=1>180.180.381.382.5</td></tr><tr><td rowspan=1 colspan=1>DeiT-tiny (Touvron et al., 2020)CPVT-Tim</td><td rowspan=1 colspan=2>66</td><td rowspan=1 colspan=1>22422242</td><td rowspan=1 colspan=2>2536.52500.7</td><td rowspan=1 colspan=1>74.575.9</td><td rowspan=1 colspan=1>82.183.0</td></tr><tr><td rowspan=2 colspan=1>DeiT-small (Touvron et al., 2020)CPVT-S $CPVT-S-GAP‡</td><td rowspan=2 colspan=2>222323</td><td rowspan=2 colspan=1>22422242224²</td><td rowspan=2 colspan=2>940.4930.5942.3</td><td rowspan=1 colspan=1>79.980.5</td><td rowspan=2 colspan=1>85.786.086.6</td></tr><tr><td rowspan=1 colspan=1>81.5</td></tr><tr><td rowspan=3 colspan=1>DeiT-base (Touvron et al.,2020)CPVT-B ‡CPVT-B-GAP‡</td><td rowspan=1 colspan=2>86</td><td rowspan=1 colspan=1>2242</td><td rowspan=1 colspan=2>292.3</td><td rowspan=1 colspan=1>81.8</td><td rowspan=1 colspan=1>86.7</td></tr><tr><td rowspan=2 colspan=2>8888</td><td rowspan=2 colspan=1>22422242</td><td rowspan=2 colspan=2>285.5290.2</td><td rowspan=1 colspan=1>82.3</td><td rowspan=2 colspan=1>87.087.7</td></tr><tr><td rowspan=1 colspan=1>82.7</td></tr></table>",
"bbox": [
196,
141,
802,
525
],
"page_idx": 6
},
{
"type": "text",
"text": "We further train CPVT-Ti and DeiT-tiny using the aforementioned training settings plus the hard distillation proposed in (Touvron et al., 2020). Specifically, we use RegNetY-160 (Radosavovic et al., 2020) as the teacher. CPVT obtains $7 5 . 9 \\%$ , exceeding DeiT-tiny by $1 . 4 \\%$ . ",
"bbox": [
176,
590,
823,
633
],
"page_idx": 6
},
{
"type": "text",
"text": "4.6 PEG ON PYRAMID TRANSFORMER ARCHITECTURES ",
"text_level": 1,
"bbox": [
174,
650,
578,
665
],
"page_idx": 6
},
{
"type": "text",
"text": "PVT (Wang et al., 2021) is a vision transformer with the multi-stage design like ResNet (He et al., 2016). Swin (Liu et al., 2021) is a follow-up work and comes with higher performance. We apply our method on both to demonstrate its generalization ability. ",
"bbox": [
174,
676,
825,
718
],
"page_idx": 6
},
{
"type": "text",
"text": "ImageNet classification. Specifically, we remove its learnable PE and apply our PEG in position 0 of each stage with a GAP head. We use the same training settings to make a fair comparison and show the results in Table 13. Our method can significantly boost PVT-tiny by $3 . 1 \\%$ and Swin-tiny by $1 . 1 5 \\%$ on ImageNet (c.f. B.5). We also evaluate the performance of PEG on some downstream semantic segmentation and object detection tasks (see B.6). Note these tasks usually handle the various input resolutions as the training because multi-scale data augmentation is extensively used. ",
"bbox": [
174,
734,
825,
818
],
"page_idx": 6
},
{
"type": "text",
"text": "5 ABLATION STUDY ",
"text_level": 1,
"bbox": [
176,
838,
356,
854
],
"page_idx": 6
},
{
"type": "text",
"text": "5.1 POSITIONAL ENCODING OR MERELY A HYBRID? ",
"text_level": 1,
"bbox": [
174,
869,
545,
883
],
"page_idx": 6
},
{
"type": "text",
"text": "One might suspect that the PEG’s improvement comes from the extra learnable parameters introduced by the convolutional layers in PEG, instead of the local relationship retained by PEG. One way to test the function of PEG is only adding it when calculating Q and K in the attention layer, so that only the positional information of PEG is passed through. We can achieve $7 1 . 3 \\%$ top-1 accuracy on ImageNet with DeiT-tiny. This is significantly better than DeiT-tiny w/o PE $( 6 8 . 2 \\% )$ and is similar to the one with PEG on Q, K and V $( 7 2 . 4 \\% )$ , which suggests that PEG mainly serves as a positional encoding scheme. ",
"bbox": [
174,
895,
823,
924
],
"page_idx": 6
},
{
"type": "text",
"text": "",
"bbox": [
173,
103,
825,
174
],
"page_idx": 7
},
{
"type": "text",
"text": "We also design another experiment to remove this concern. By randomly-initializing a $3 \\times 3$ PEG and fixing its weights during the training, we can obtain $7 1 . 3 \\%$ accuracy (Table 5), which is much higher $( 3 . 1 \\% \\uparrow )$ than DeiT without any PE $( 6 8 . 2 \\% )$ . Since the weights of PEG are fixed and the performance improvement can only be due to the introduced position information. On the contrary, when we exhaustively use 12 convolutional layers (kernel size being 1, i.e., not producing local relationship) to replace the PEG, these layers have much more ",
"bbox": [
174,
181,
483,
347
],
"page_idx": 7
},
{
"type": "table",
"img_path": "images/11790728028cd9dbe8edf5d3fdf3853d3c301a8b464af0a0b87bab1c3bc3cc46.jpg",
"table_caption": [
"Table 5. Positional encoding rather than added parameters gives the most improvement "
],
"table_footnote": [
"learnable parameters than PEG. However, it only boosts the performance by $0 . 4 \\%$ to $6 8 . 6 \\%$ "
],
"table_body": "<table><tr><td>Kernel</td><td>Style</td><td>Params (M)</td><td>Top-1 Acc (%)</td></tr><tr><td>none 3</td><td></td><td>5.68</td><td>68.2</td></tr><tr><td>3</td><td>fixed (random init)</td><td>5.68</td><td>71.3</td></tr><tr><td>1(12 ×)</td><td>fixed (learned init)</td><td>5.68</td><td>72.3</td></tr><tr><td></td><td>learnable</td><td>6.13</td><td>68.6</td></tr><tr><td>3</td><td>learnable</td><td>5.68</td><td>72.4</td></tr></table>",
"bbox": [
496,
226,
833,
327
],
"page_idx": 7
},
{
"type": "text",
"text": "Another interesting finding is that fixing a learned PEG also helps training. When we initialize with a learned PEG instead of the random values and train the tiny version of the model from scratch while keeping the PEG fixed, the model can also achieve $7 2 . 3 \\%$ top-1 accuracy on ImageNet. This is very close to the learnable PEG $( 7 2 . 4 \\% )$ . ",
"bbox": [
174,
367,
825,
424
],
"page_idx": 7
},
{
"type": "text",
"text": "5.2 PEG POSITION IN CPVT ",
"text_level": 1,
"bbox": [
174,
444,
387,
458
],
"page_idx": 7
},
{
"type": "text",
"text": "We also experiment by varying the position of the PEG in the model. Table 6 (left) presents the ablations for variable positions (denoted as PosIdx) based on the tiny model. We consider the input of the first encoder by index -1. Therefore, position 0 is the output of the first encoder block. PEG shows strong performance $( \\sim 7 2 . 4 \\% )$ when it is placed at [0, 3]. ",
"bbox": [
174,
472,
825,
527
],
"page_idx": 7
},
{
"type": "text",
"text": "Note that positioning the PEG at 0 can have much better performance than positioning it at -1 (i.e., before the first encoder), as shown in Table 6 (left). We observe that the difference between the two situations is they have different receptive fields. Specifically, the former has a global field while the latter can only see a local area. Hence, they are supposed to work similarly well if we enlarge the convolution’s kernel size. To verify our hypothesis, we use a quite large kernel size 27 with a padding size 13 at position -1, whose result is reported in Table 6 (right). It achieves similar performance to the one positioning the PEG at 0 $( 7 2 . 5 \\% )$ , which verifies our assumption. ",
"bbox": [
173,
534,
825,
632
],
"page_idx": 7
},
{
"type": "table",
"img_path": "images/0481d99dee42f3e65399bd2ca0e28796db6647911c0f5a0ee152c022cd181da9.jpg",
"table_caption": [
"Table 6. Comparison of different plugin positions (left) and kernels (right) using DeiT-tiny "
],
"table_footnote": [],
"table_body": "<table><tr><td>PosIdx</td><td>Top-1 (%)</td><td>Top-5 (%)</td></tr><tr><td>none -1</td><td>68.2</td><td>88.7</td></tr><tr><td rowspan=\"4\">0 3</td><td>70.6</td><td>90.2</td></tr><tr><td>72.4</td><td>91.2</td></tr><tr><td>72.3</td><td>91.1</td></tr><tr><td>71.7</td><td>90.8</td></tr><tr><td>6 10</td><td>69.0</td><td>89.1</td></tr></table>",
"bbox": [
187,
681,
428,
781
],
"page_idx": 7
},
{
"type": "table",
"img_path": "images/8f8db5718255214be93af4acfd1c2a152c0682df2fbe744bcae9d8859becad24.jpg",
"table_caption": [],
"table_footnote": [],
"table_body": "<table><tr><td>PosIdx</td><td>kernel</td><td>Params</td><td>Top-1 (%)</td><td>Top-5 (%)</td></tr><tr><td>-1</td><td>3×3</td><td>5.7M</td><td>70.6</td><td>90.2</td></tr><tr><td>-1</td><td>27×27</td><td>5.8M</td><td>72.5</td><td>91.3</td></tr></table>",
"bbox": [
436,
709,
810,
753
],
"page_idx": 7
},
{
"type": "text",
"text": "5.3 COMPARISONS WITH OTHER POSITIONAL ENCODINGS ",
"text_level": 1,
"bbox": [
173,
819,
584,
833
],
"page_idx": 7
},
{
"type": "text",
"text": "We compare PEG with other commonly used encodings: absolute positional encoding (e.g. sinusoidal (Vaswani et al., 2017)), relative positional encoding (RPE) (Shaw et al., 2018) and learnable encoding (LE) (Devlin et al., 2019; Radford et al., 2018), as shown in Table 7. ",
"bbox": [
174,
845,
825,
888
],
"page_idx": 7
},
{
"type": "text",
"text": "DeiT-tiny obtains $7 2 . 2 \\%$ with the learnable absolute PE. We experiment with the 2-D sinusoidal encodings and it achieves on-par performance. For RPE, we follow (Shaw et al., 2018) and set the local range hyper-parameter $K$ as 8, with which we obtain $70 . 5 \\%$ . RPE here does not encode any absolute position information, see discussion in D.1 and B.3. ",
"bbox": [
174,
895,
823,
924
],
"page_idx": 7
},
{
"type": "table",
"img_path": "images/95fd6a569fa1244f963febaf9a0efdc3cfabf31651fb6fcb321724eff294eb94.jpg",
"table_caption": [
"Table 7. Comparison of various positional encoding strategies. LE: learnable positional encoding. RPE: relative positional encoding "
],
"table_footnote": [],
"table_body": "<table><tr><td>Model</td><td>PEG Pos</td><td>Encoding</td><td>Top-1 (%)</td><td>Top-5 (%)</td></tr><tr><td>DeiT-tiny (2020)</td><td></td><td>LE</td><td>72.2 72.3</td><td>91.0 91.0</td></tr><tr><td>DeiT-tiny DeiT-tiny</td><td></td><td>2D sin-cos 2DRPE</td><td>70.5</td><td>90.0</td></tr><tr><td>CPVT-Ti</td><td>= 0-1</td><td>PEG</td><td>72.4</td><td>91.2</td></tr><tr><td>CPVT-Ti</td><td>0-1</td><td>PEG+LE</td><td>72.9</td><td>91.4</td></tr><tr><td>CPVT-Ti</td><td>0-1</td><td>4×PEG+LE</td><td>72.9</td><td></td></tr><tr><td></td><td>0-5</td><td></td><td></td><td>91.4</td></tr><tr><td>CPVT-Ti</td><td></td><td>PEG</td><td>73.4</td><td>91.8</td></tr></table>",
"bbox": [
313,
135,
684,
263
],
"page_idx": 8
},
{
"type": "text",
"text": "",
"bbox": [
174,
295,
821,
323
],
"page_idx": 8
},
{
"type": "text",
"text": "Moreover, we combine the learnable absolute PE with a single-layer PEG. This boosts the baseline CPVT-Ti (0-1) by $0 . 5 \\%$ . If we use 4-layer PEG, it can achieve $7 2 . 9 \\%$ . If we add a PEG to each of the first five blocks, we can obtain $7 3 . 4 \\%$ , which is better than stacking them within one block. ",
"bbox": [
174,
330,
823,
372
],
"page_idx": 8
},
{
"type": "text",
"text": "CPE is not a simple combination of APE and RPE. We further compare our method with a baseline with combination of APE and RPE. Specifically, we use learnable positional encoding (LE) as DeiT at the beginning of the model and supply 2D RPE for every transformer block. This setting achieves $7 2 . 4 \\%$ top-1 accuracy on ImageNet, which is comparable to a single PEG $( 7 2 . 4 \\% )$ . Nevertheless, this experiment does not necessarily indicate that our CPE is a simple combination of APE and RPE. When tested on different resolutions, this baseline cannot scale well compared to ours (Table 8). RPE is not able to adequately mitigate the performance degradation on top of LE. This shall be seen as a major difference. ",
"bbox": [
173,
378,
825,
491
],
"page_idx": 8
},
{
"type": "table",
"img_path": "images/6b8d3b6d4e5b316d0cd1fa2df431aa65ca8ce37bb57e56b851d5cb5d959fbc3f.jpg",
"table_caption": [
"Table 8. Direct evaluation on other resolutions without fine-tuning. The models are trained on $2 2 4 \\times 2 2 4$ . CPE outperforms $\\mathrm { L E + R P E }$ combination on untrained resolutions. "
],
"table_footnote": [],
"table_body": "<table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>PositionalParams</td><td rowspan=1 colspan=1>160(%)</td><td rowspan=1 colspan=1>224(%)</td><td rowspan=1 colspan=1>384(%)</td><td rowspan=1 colspan=1>448(%)</td><td rowspan=1 colspan=1>512(%)</td></tr><tr><td rowspan=1 colspan=1>DeiT-tiny (LE+RPE)DeiT-tiny (PEG at Pos 0)</td><td rowspan=1 colspan=1>400111920</td><td rowspan=1 colspan=1>65.666.8</td><td rowspan=1 colspan=1>72.472.4</td><td rowspan=1 colspan=1>70.873.2</td><td rowspan=1 colspan=1>68.471.8</td><td rowspan=1 colspan=1>65.670.3</td></tr></table>",
"bbox": [
200,
551,
797,
597
],
"page_idx": 8
},
{
"type": "text",
"text": "PEG can continuously improve the performance if stacked more. We use LE not only at the beginning but also in the next 5 layers to have a similar thing as 0-5 PEG configuration.This setting achieves $7 2 . 7 \\%$ top-1 accuracy on ImageNet, which is $0 . 7 \\%$ lower than PEG (0-5). This setting suggests that it is also beneficial to have more of LEs, but not as good as ours. It is expected since we exploit relative information via PEGs at the same time. ",
"bbox": [
174,
617,
825,
686
],
"page_idx": 8
},
{
"type": "text",
"text": "6 CONCLUSION ",
"text_level": 1,
"bbox": [
176,
707,
318,
723
],
"page_idx": 8
},
{
"type": "text",
"text": "We introduced CPVT, a novel method to provide the position information in vision transformers, which dynamically generates the position encodings based on the local neighbors of each input token. Through extensive experimental studies, we demonstrate that our proposed positional encodings can achieve stronger performance than the previous positional encodings. The transformer models with our positional encodings can naturally process longer input sequences and keep the desired translation equivalence in vision tasks. Moreover, our positional encodings are easy to implement and come with negligible cost. We look forward to a broader application of our method in transformer-driven vision tasks like segmentation and video processing. ",
"bbox": [
174,
738,
825,
851
],
"page_idx": 8
},
{
"type": "text",
"text": "REFERENCES ",
"text_level": 1,
"bbox": [
176,
872,
285,
887
],
"page_idx": 8
},
{
"type": "text",
"text": "Mart´ın Abadi, Paul Barham, Jianmin Chen, Zhifeng Chen, Andy Davis, Jeffrey Dean, Matthieu Devin, Sanjay Ghemawat, Geoffrey Irving, Michael Isard, et al. Tensorflow: A system for largescale machine learning. In 12th {USENIX} symposium on operating systems design and implementation ({OSDI} 16), pp. 265–283, 2016. ",
"bbox": [
178,
895,
823,
924
],
"page_idx": 8
},
{
"type": "text",
"text": "",
"bbox": [
181,
103,
823,
132
],
"page_idx": 9
},
{
"type": "text",
"text": "Irwan Bello. Lambdanetworks: Modeling long-range interactions without attention. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum? id=xTJEN-ggl1b. ",
"bbox": [
176,
141,
823,
184
],
"page_idx": 9
},
{
"type": "text",
"text": "Irwan Bello, Barret Zoph, Ashish Vaswani, Jonathon Shlens, and Quoc V Le. Attention augmented convolutional networks. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 3286–3295, 2019. ",
"bbox": [
173,
193,
825,
236
],
"page_idx": 9
},
{
"type": "text",
"text": "Lucas Beyer, Olivier J Henaff, Alexander Kolesnikov, Xiaohua Zhai, and A ´ aron van den Oord. Are ¨ we done with imagenet? arXiv preprint arXiv:2006.07159, 2020. ",
"bbox": [
171,
244,
823,
273
],
"page_idx": 9
},
{
"type": "text",
"text": "Tom B Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. arXiv preprint arXiv:2005.14165, 2020. ",
"bbox": [
173,
282,
825,
325
],
"page_idx": 9
},
{
"type": "text",
"text": "Nicolas Carion, Francisco Massa, Gabriel Synnaeve, Nicolas Usunier, Alexander Kirillov, and Sergey Zagoruyko. End-to-end object detection with transformers. In European Conference on Computer Vision, pp. 213–229. Springer, 2020. ",
"bbox": [
174,
334,
825,
378
],
"page_idx": 9
},
{
"type": "text",
"text": "Hanting Chen, Yunhe Wang, Tianyu Guo, Chang Xu, Yiping Deng, Zhenhua Liu, Siwei Ma, Chunjing Xu, Chao Xu, and Wen Gao. Pre-trained image processing transformer. arXiv preprint arXiv:2012.00364, 2020. ",
"bbox": [
173,
386,
825,
429
],
"page_idx": 9
},
{
"type": "text",
"text": "Tianqi Chen, Mu Li, Yutian Li, Min Lin, Naiyan Wang, Minjie Wang, Tianjun Xiao, Bing Xu, Chiyuan Zhang, and Zheng Zhang. Mxnet: A flexible and efficient machine learning library for heterogeneous distributed systems. arXiv preprint arXiv:1512.01274, 2015. ",
"bbox": [
173,
438,
823,
482
],
"page_idx": 9
},
{
"type": "text",
"text": "Xiangxiang Chu, Zhi Tian, Yuqing Wang, Bo Zhang, Haibing Ren, Xiaolin Wei, Huaxia Xia, and Chunhua Shen. Twins: Revisiting the design of spatial attention in vision transformers. In NeurIPS 2021, 2021. ",
"bbox": [
174,
489,
823,
534
],
"page_idx": 9
},
{
"type": "text",
"text": "Jean-Baptiste Cordonnier, Andreas Loukas, and Martin Jaggi. On the relationship between selfattention and convolutional layers. In International Conference on Learning Representations, 2020. ",
"bbox": [
174,
541,
825,
585
],
"page_idx": 9
},
{
"type": "text",
"text": "Ekin Dogus Cubuk, Barret Zoph, Jon Shlens, and Quoc Le. Randaugment: Practical automated data augmentation with a reduced search space. Advances in Neural Information Processing Systems, 33, 2020. ",
"bbox": [
173,
593,
825,
637
],
"page_idx": 9
},
{
"type": "text",
"text": "Zihang Dai, Hanxiao Liu, Quoc Le, and Mingxing Tan. Coatnet: Marrying convolution and attention for all data sizes. Advances in Neural Information Processing Systems, 34, 2021. ",
"bbox": [
171,
645,
821,
675
],
"page_idx": 9
},
{
"type": "text",
"text": "Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pp. 248–255. Ieee, 2009. ",
"bbox": [
173,
684,
825,
727
],
"page_idx": 9
},
{
"type": "text",
"text": "Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 4171–4186, 2019. ",
"bbox": [
173,
736,
826,
792
],
"page_idx": 9
},
{
"type": "text",
"text": "Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations, 2021. URL https: //openreview.net/forum?id $=$ YicbFdNTTy. ",
"bbox": [
174,
801,
825,
872
],
"page_idx": 9
},
{
"type": "text",
"text": "Stephane d’Ascoli, Hugo Touvron, Matthew L Leavitt, Ari S Morcos, Giulio Biroli, and Levent ´ Sagun. Convit: Improving vision transformers with soft convolutional inductive biases. In International Conference on Machine Learning, pp. 2286–2296. PMLR, 2021. ",
"bbox": [
176,
882,
823,
924
],
"page_idx": 9
},
{
"type": "text",
"text": "Anmol Gulati, James Qin, Chung-Cheng Chiu, Niki Parmar, Yu Zhang, Jiahui Yu, Wei Han, Shibo Wang, Zhengdong Zhang, Yonghui Wu, et al. Conformer: Convolution-augmented transformer for speech recognition. arXiv preprint arXiv:2005.08100, 2020. ",
"bbox": [
176,
103,
823,
146
],
"page_idx": 10
},
{
"type": "text",
"text": "Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 770–778, 2016. ",
"bbox": [
176,
154,
821,
196
],
"page_idx": 10
},
{
"type": "text",
"text": "Pengcheng He, Xiaodong Liu, Jianfeng Gao, and Weizhu Chen. Deberta: Decoding-enhanced bert with disentangled attention. arXiv preprint arXiv:2006.03654, 2020. ",
"bbox": [
173,
205,
823,
234
],
"page_idx": 10
},
{
"type": "text",
"text": "Elad Hoffer, Tal Ben-Nun, Itay Hubara, Niv Giladi, Torsten Hoefler, and Daniel Soudry. Augment your batch: Improving generalization through instance repetition. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 8129–8138, 2020. ",
"bbox": [
176,
242,
823,
286
],
"page_idx": 10
},
{
"type": "text",
"text": "Cheng-Zhi Anna Huang, Ashish Vaswani, Jakob Uszkoreit, Noam Shazeer, Ian Simon, Curtis Hawthorne, Andrew M Dai, Matthew D Hoffman, Monica Dinculescu, and Douglas Eck. Music transformer. In Advances in Neural Processing Systems, 2018. ",
"bbox": [
173,
294,
826,
337
],
"page_idx": 10
},
{
"type": "text",
"text": "Gao Huang, Yu Sun, Zhuang Liu, Daniel Sedra, and Kilian Q Weinberger. Deep networks with stochastic depth. In European conference on computer vision, pp. 646–661. Springer, 2016. ",
"bbox": [
173,
344,
825,
375
],
"page_idx": 10
},
{
"type": "text",
"text": "Md Amirul Islam, Sen Jia, and Neil DB Bruce. How much position information do convolutional neural networks encode? In International Conference on Learning Representations, 2020. ",
"bbox": [
174,
382,
823,
412
],
"page_idx": 10
},
{
"type": "text",
"text": "Alexander Kirillov, Ross Girshick, Kaiming He, and Piotr Dollar. Panoptic feature pyramid net- ´ works. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 6399–6408, 2019. ",
"bbox": [
174,
419,
825,
463
],
"page_idx": 10
},
{
"type": "text",
"text": "Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dollar. Focal loss for dense´ object detection. In Proceedings of the IEEE international conference on computer vision, pp. 2980–2988, 2017. ",
"bbox": [
174,
470,
825,
513
],
"page_idx": 10
},
{
"type": "text",
"text": "Xuanqing Liu, Hsiang-Fu Yu, Inderjit Dhillon, and Cho-Jui Hsieh. Learning to encode position for transformer with continuous dynamical model. In International Conference on Machine Learning, pp. 6327–6335. PMLR, 2020. ",
"bbox": [
174,
522,
825,
565
],
"page_idx": 10
},
{
"type": "text",
"text": "Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. arXiv preprint arXiv:2103.14030, 2021. ",
"bbox": [
173,
573,
825,
616
],
"page_idx": 10
},
{
"type": "text",
"text": "Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id $\\underline { { \\underline { { \\mathbf { \\Pi } } } } } =$ Bkg6RiCqY7. ",
"bbox": [
173,
625,
821,
667
],
"page_idx": 10
},
{
"type": "text",
"text": "Abdelrahman Mohamed, Dmytro Okhonko, and Luke Zettlemoyer. Transformers with convolutional context for asr. arXiv preprint arXiv:1904.11660, 2019. ",
"bbox": [
169,
676,
823,
705
],
"page_idx": 10
},
{
"type": "text",
"text": "Niki Parmar, Ashish Vaswani, Jakob Uszkoreit, Lukasz Kaiser, Noam Shazeer, Alexander Ku, and Dustin Tran. Image transformer. In Jennifer Dy and Andreas Krause (eds.), Proceedings of the 35th International Conference on Machine Learning, volume 80 of Proceedings of Machine Learning Research, pp. 4055–4064, Stockholmsmassan, Stockholm Sweden, 10–15 Jul 2018. ¨ PMLR. ",
"bbox": [
174,
713,
826,
784
],
"page_idx": 10
},
{
"type": "text",
"text": "Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, et al. Pytorch: An imperative style, high-performance deep learning library. Advances in Neural Information Processing Systems, 32: 8026–8037, 2019. ",
"bbox": [
173,
792,
825,
849
],
"page_idx": 10
},
{
"type": "text",
"text": "Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving language understanding by generative pre-training. 2018. ",
"bbox": [
173,
858,
820,
887
],
"page_idx": 10
},
{
"type": "text",
"text": "Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. OpenAI blog, 1(8):9, 2019. ",
"bbox": [
174,
895,
821,
924
],
"page_idx": 10
},
{
"type": "text",
"text": "Ilija Radosavovic, Raj Prateek Kosaraju, Ross Girshick, Kaiming He, and Piotr Dollar. Designing ´ network design spaces. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 10428–10436, 2020. ",
"bbox": [
176,
103,
821,
145
],
"page_idx": 11
},
{
"type": "text",
"text": "Prajit Ramachandran, Niki Parmar, Ashish Vaswani, Irwan Bello, Anselm Levskaya, and Jon Shlens. Stand-alone self-attention in vision models. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d'Alche-Buc, E. Fox, and R. Garnett (eds.), ´ Advances in Neural Information Processing Systems, volume 32, pp. 68–80. Curran Associates, Inc., 2019. URL https://proceedings.neurips.cc/paper/2019/file/ 3416a75f4cea9109507cacd8e2f2aefc-Paper.pdf. ",
"bbox": [
173,
157,
825,
241
],
"page_idx": 11
},
{
"type": "text",
"text": "Peter Shaw, Jakob Uszkoreit, and Ashish Vaswani. Self-attention with relative position representations. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 2, pp. 464–468, 2018. ",
"bbox": [
176,
252,
823,
295
],
"page_idx": 11
},
{
"type": "text",
"text": "Nitish Srivastava, Geoffrey Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. Dropout: a simple way to prevent neural networks from overfitting. The journal of machine learning research, 15(1):1929–1958, 2014. ",
"bbox": [
176,
306,
821,
348
],
"page_idx": 11
},
{
"type": "text",
"text": "Jianlin Su, Yu Lu, Shengfeng Pan, Bo Wen, and Yunfeng Liu. Roformer: Enhanced transformer with rotary position embedding. arXiv preprint arXiv:2104.09864, 2021. ",
"bbox": [
173,
359,
823,
388
],
"page_idx": 11
},
{
"type": "text",
"text": "Chen Sun, Abhinav Shrivastava, Saurabh Singh, and Abhinav Gupta. Revisiting unreasonable effectiveness of data in deep learning era. In Proceedings of the IEEE international conference on computer vision, pp. 843–852, 2017. ",
"bbox": [
173,
398,
825,
443
],
"page_idx": 11
},
{
"type": "text",
"text": "Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2818–2826, 2016. ",
"bbox": [
174,
453,
823,
496
],
"page_idx": 11
},
{
"type": "text",
"text": "Mingxing Tan and Quoc Le. Efficientnet: Rethinking model scaling for convolutional neural networks. In International Conference on Machine Learning, pp. 6105–6114. PMLR, 2019. ",
"bbox": [
173,
507,
821,
536
],
"page_idx": 11
},
{
"type": "text",
"text": "Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and Herve J ´ egou. Training data-efficient image transformers & distillation through attention. ´ arXiv preprint arXiv:2012.12877, 2020. ",
"bbox": [
173,
546,
825,
589
],
"page_idx": 11
},
{
"type": "text",
"text": "Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Proceedings of the 31st International Conference on Neural Information Processing Systems, pp. 6000–6010, 2017. ",
"bbox": [
173,
599,
823,
643
],
"page_idx": 11
},
{
"type": "text",
"text": "Benyou Wang, Donghao Zhao, Christina Lioma, Qiuchi Li, Peng Zhang, and Jakob Grue Simonsen. Encoding word order in complex embeddings. arXiv preprint arXiv:1912.12333, 2019. ",
"bbox": [
171,
654,
821,
683
],
"page_idx": 11
},
{
"type": "text",
"text": "Wenhai Wang, Enze Xie, Xiang Li, Deng-Ping Fan, Kaitao Song, Ding Liang, Tong Lu, Ping Luo, and Ling Shao. Pyramid vision transformer: A versatile backbone for dense prediction without convolutions. arXiv preprint arXiv:2102.12122, 2021. ",
"bbox": [
173,
694,
825,
737
],
"page_idx": 11
},
{
"type": "text",
"text": "Yuqing Wang, Zhaoliang Xu, Xinlong Wang, Chunhua Shen, Baoshan Cheng, Hao Shen, and Huaxia Xia. End-to-end video instance segmentation with transformers. arXiv preprint arXiv:2011.14503, 2020. ",
"bbox": [
174,
747,
825,
790
],
"page_idx": 11
},
{
"type": "text",
"text": "Haiping Wu, Bin Xiao, Noel Codella, Mengchen Liu, Xiyang Dai, Lu Yuan, and Lei Zhang. Cvt: Introducing convolutions to vision transformers. arXiv preprint arXiv:2103.15808, 2021. ",
"bbox": [
169,
801,
823,
830
],
"page_idx": 11
},
{
"type": "text",
"text": "Baosong Yang, Longyue Wang, Derek Wong, Lidia S Chao, and Zhaopeng Tu. Convolutional selfattention networks. arXiv preprint arXiv:1904.03107, 2019a. ",
"bbox": [
169,
842,
823,
871
],
"page_idx": 11
},
{
"type": "text",
"text": "Zhilin Yang, Zihang Dai, Yiming Yang, Jaime Carbonell, Ruslan Salakhutdinov, and Quoc V Le. Xlnet: Generalized autoregressive pretraining for language understanding. arXiv preprint arXiv:1906.08237, 2019b. ",
"bbox": [
174,
882,
825,
922
],
"page_idx": 11
},
{
"type": "text",
"text": "Adams Wei Yu, David Dohan, Minh-Thang Luong, Rui Zhao, Kai Chen, Mohammad Norouzi, and Quoc V Le. Qanet: Combining local convolution with global self-attention for reading comprehension. arXiv preprint arXiv:1804.09541, 2018. ",
"bbox": [
176,
103,
823,
146
],
"page_idx": 12
},
{
"type": "text",
"text": "Sangdoo Yun, Dongyoon Han, Seong Joon Oh, Sanghyuk Chun, Junsuk Choe, and Youngjoon Yoo. Cutmix: Regularization strategy to train strong classifiers with localizable features. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 6023–6032, 2019. ",
"bbox": [
178,
155,
821,
198
],
"page_idx": 12
},
{
"type": "text",
"text": "Hongyi Zhang, Moustapha Cisse, Yann N. Dauphin, and David Lopez-Paz. mixup: Beyond empirical risk minimization. In International Conference on Learning Representations, 2018. URL https://openreview.net/forum?id $\\underline { { \\underline { { \\mathbf { \\Pi } } } } } =$ r1Ddp1-Rb. ",
"bbox": [
176,
205,
821,
250
],
"page_idx": 12
},
{
"type": "text",
"text": "Sixiao Zheng, Jiachen Lu, Hengshuang Zhao, Xiatian Zhu, Zekun Luo, Yabiao Wang, Yanwei Fu, Jianfeng Feng, Tao Xiang, Philip HS Torr, et al. Rethinking semantic segmentation from a sequence-to-sequence perspective with transformers. arXiv preprint arXiv:2012.15840, 2020. ",
"bbox": [
174,
257,
825,
301
],
"page_idx": 12
},
{
"type": "text",
"text": "Zhun Zhong, Liang Zheng, Guoliang Kang, Shaozi Li, and Yi Yang. Random erasing data augmentation. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pp. 13001–13008, 2020. ",
"bbox": [
173,
309,
823,
352
],
"page_idx": 12
},
{
"type": "text",
"text": "Bolei Zhou, Hang Zhao, Xavier Puig, Sanja Fidler, Adela Barriuso, and Antonio Torralba. Scene parsing through ade20k dataset. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 633–641, 2017. ",
"bbox": [
173,
361,
823,
404
],
"page_idx": 12
},
{
"type": "text",
"text": "Xizhou Zhu, Weijie Su, Lewei Lu, Bin Li, Xiaogang Wang, and Jifeng Dai. Deformable detr: Deformable transformers for end-to-end object detection. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id ${ . } =$ gZ9hCDWe6ke. ",
"bbox": [
173,
412,
823,
455
],
"page_idx": 12
},
{
"type": "text",
"text": "A TRANSLATION EQUIVARIANCE ",
"text_level": 1,
"bbox": [
176,
102,
465,
118
],
"page_idx": 13
},
{
"type": "text",
"text": "The term translation-equivariance means the output feature maps can be equally translated with the input signal. Imagine there is a person in the left-top of an image, if the person is moved to the right-bottom, the output feature maps will change accordingly. This property is very important to the success of convolution network. Convolution (ignoring paddings), RPE, and self-attention are all translation-equivariant operations (regardless of their receptive field). It’s nontrivial to make absolute positional encodings like DeiT (using learnable positional encoding) translation-equivariant since different absolute positions will be added if the input signal is translated. Note that our method is not strictly translation-equivariant because of the zero padding. Instead, it provides a kind of stronger explicit bias towards the translation-equivariant property. ",
"bbox": [
174,
133,
825,
260
],
"page_idx": 13
},
{
"type": "text",
"text": "B EXPERIMENT DETAILS ",
"text_level": 1,
"bbox": [
176,
280,
398,
295
],
"page_idx": 13
},
{
"type": "text",
"text": "B.1 ARCHITECTURE VARIANTS OF CPVT ",
"text_level": 1,
"bbox": [
176,
310,
473,
325
],
"page_idx": 13
},
{
"type": "table",
"img_path": "images/2d0f7ad56c59c2d4c1f15b5e9b951e289749c3731062b05327bb45b3c7e140dd.jpg",
"table_caption": [
"Table 9. CPVT architecture variants. The larger model, CPVT-B, has the same architecture as ViTB (Dosovitskiy et al., 2021) and DeiT-B (Touvron et al., 2020). CPVT-S and CPVT-Ti have the same architecture as DeiT-small and DeiT-tiny respectively "
],
"table_footnote": [],
"table_body": "<table><tr><td>Model</td><td>#channels</td><td>#heads</td><td>#layers</td><td>#params</td></tr><tr><td>CPVT-Ti</td><td>192</td><td>3</td><td>12</td><td>6M</td></tr><tr><td>CPVT-S</td><td>384</td><td>6</td><td>12</td><td>22M</td></tr><tr><td>CPVT-B</td><td>768</td><td>12</td><td>12</td><td>86M</td></tr></table>",
"bbox": [
349,
401,
647,
455
],
"page_idx": 13
},
{
"type": "text",
"text": "B.2 THE HYPERPARAMETERS OF CPVT ",
"text_level": 1,
"bbox": [
176,
489,
464,
503
],
"page_idx": 13
},
{
"type": "text",
"text": "As for the ImageNet classification task, we use exactly the same hyperparameters as DeiT except for the base model because it is not always stably trained using AdamW. The detailed setting is shown in Table 10. ",
"bbox": [
176,
515,
826,
558
],
"page_idx": 13
},
{
"type": "table",
"img_path": "images/164ce8cb1f4d7b162d7d0eb721d68b501123589b84ae390079aa08d3889b476d.jpg",
"table_caption": [
"Table 10. Hyper-parameters for ViT, DeiT and CPVT "
],
"table_footnote": [],
"table_body": "<table><tr><td>Methods</td><td>ViT</td><td>DeiT</td><td>CPVT</td></tr><tr><td>Epochs Batch size</td><td>300 4096</td><td>300 1024</td><td>300 1024</td></tr><tr><td>Optimizer</td><td>AdamW</td><td>AdamW</td><td>LAMB</td></tr><tr><td>Learning rate decay</td><td>cosine</td><td>cosine</td><td>cosine</td></tr><tr><td>Weight decay</td><td>0.3</td><td>0.05</td><td>0.05</td></tr><tr><td>Warmup epochs</td><td>3.4</td><td>5</td><td>5</td></tr><tr><td>Label smoothing ε (Szegedy et al., 2016)</td><td>X</td><td>0.1 X</td><td>0.1</td></tr><tr><td>Dropout (Srivastava et al.,2014)</td><td>0.1</td><td></td><td>X</td></tr><tr><td>Stoch.Depth (Huang et al., 2016)</td><td>X</td><td>0.1 √</td><td>0.1</td></tr><tr><td>Repeated Aug (Hoffer et al., 2020)</td><td>X</td><td>X</td><td>√</td></tr><tr><td>Gradient Clip.</td><td>√</td><td>9/0.5</td><td>X</td></tr><tr><td>Rand Augment (Cubuk et al., 2020)</td><td>X</td><td></td><td>9/0.5</td></tr><tr><td>Mixup prob. (Zhang et al.,2018)</td><td>X</td><td>0.8</td><td>0.8</td></tr><tr><td>Cutmix prob. (Yun et al., 2019)</td><td>X</td><td>1.0</td><td>1.0</td></tr><tr><td>Erasing prob. (Zhong et al.,2020)</td><td>X</td><td>0.25</td><td>0.25</td></tr></table>",
"bbox": [
267,
594,
728,
800
],
"page_idx": 13
},
{
"type": "text",
"text": "B.3 IMPORTANCE OF ZERO PADDINGS ",
"text_level": 1,
"bbox": [
176,
827,
450,
842
],
"page_idx": 13
},
{
"type": "text",
"text": "We design an experiment to verify the importance of the zero paddings, which can help the model infer the absolute positional information. Specifically, we use CPVT-S and simply remove the zero paddings from CPVT while keeping all other settings unchanged. Table 11 shows that this can only obtain $7 0 . 5 \\%$ , which indicates that the zero paddings and absolute positional information play important roles in classifying objects. ",
"bbox": [
174,
853,
825,
924
],
"page_idx": 13
},
{
"type": "table",
"img_path": "images/88c034eed6fc8b897c16fd609b0747d75c5d2d484b983f1b2b68b89b5089c291.jpg",
"table_caption": [
"Table 11. Ablation study on ImageNet performance w/ or w/o zero paddings "
],
"table_footnote": [],
"table_body": "<table><tr><td>Model</td><td>Padding</td><td>Top-1 Acc(%)</td><td>Top-5 Acc(%)</td></tr><tr><td rowspan=\"2\">CPVT-Ti</td><td>√</td><td>72.4</td><td>91.2</td></tr><tr><td>X</td><td>70.5</td><td>89.8</td></tr></table>",
"bbox": [
320,
133,
676,
175
],
"page_idx": 14
},
{
"type": "text",
"text": "B.4 SINGLE PEG VS. MULTIPLE PEGS",
"text_level": 1,
"bbox": [
176,
210,
457,
224
],
"page_idx": 14
},
{
"type": "text",
"text": "We further evaluate whether or not using multi-position encodings can benefit the performance in Table 12. Notice we denote by $i \\mathrm { - } j$ the inserted positions of PEG which start from the $i$ -th encoder and end at the $j - 1$ -th one (inclusion). By inserting PEGs to five positions, the top-1 accuracy of the tiny model can achieve $7 3 . 4 \\%$ , which surpasses DeiT-tiny by $1 . 2 \\%$ . Similarly, CPVT-S can achieve $8 0 . 5 \\%$ . It turns out more PEGs do help, but up to a level where more PEGs become incremental (0-5 vs. 0-11). ",
"bbox": [
173,
238,
826,
321
],
"page_idx": 14
},
{
"type": "table",
"img_path": "images/0b5b1050203055bb3eb14543fdc8cd11d9192d3c5b12399d875656aeaac37c17.jpg",
"table_caption": [
"Table 12. CPVT’s sensitivity to number of plugin positions "
],
"table_footnote": [],
"table_body": "<table><tr><td>Positions</td><td>Model</td><td>Params (M)</td><td>Top-1 Acc (%)</td><td>Top-5 Acc (%)</td></tr><tr><td>0-1</td><td>tiny</td><td>5.7</td><td>72.4</td><td>91.2</td></tr><tr><td>0-5</td><td>tiny</td><td>5.9</td><td>73.4</td><td>91.8</td></tr><tr><td>0-11</td><td>tiny</td><td>6.1</td><td>73.4</td><td>91.8</td></tr><tr><td>0-1 0-5</td><td>small small</td><td>22.0 22.9</td><td>79.9 80.5</td><td>95.0 95.2</td></tr></table>",
"bbox": [
343,
369,
655,
474
],
"page_idx": 14
},
{
"type": "text",
"text": "B.5 CLASSFICATION EVALUATION OF SWIN WITH PEG",
"text_level": 1,
"bbox": [
173,
512,
568,
526
],
"page_idx": 14
},
{
"type": "text",
"text": "We show the validation curves when training Swin (Liu et al., 2021) equipped with PEG in Figure 4. \nIt can boost Swin-tiny from $8 1 . 1 0 \\%$ to $8 2 . 2 5 \\%$ $( + 1 . 1 5 \\% \\uparrow )$ on ImageNet. ",
"bbox": [
169,
540,
821,
569
],
"page_idx": 14
},
{
"type": "image",
"img_path": "images/37115738de8c41b823e0aa8bb65e1c60638e6d07fe274cb734b5b2f7bcc4fd09.jpg",
"image_caption": [
"Figure 4. CPE boosts Swin Tiny on ImageNet by $1 . 1 5 \\%$ top-1 Acc. "
],
"image_footnote": [],
"bbox": [
312,
584,
686,
699
],
"page_idx": 14
},
{
"type": "text",
"text": "B.6 EVALUATION ON SEGMENTATION AND DETECTION ",
"text_level": 1,
"bbox": [
173,
765,
570,
780
],
"page_idx": 14
},
{
"type": "text",
"text": "Semantic segmentation on ADE20K. We evaluate the performance of PEG on the ADE20K (Zhou et al., 2017) segmentation task. Based on the Semantic FPN framework (Kirillov et al., 2019), PVT achieves much better results than ResNet (He et al., 2016) baselines. Under carefully controlled settings, PEG further boosts PVT-tiny by $3 . 1 \\%$ mIoU. ",
"bbox": [
173,
792,
825,
848
],
"page_idx": 14
},
{
"type": "text",
"text": "Object detection on COCO. We also perform controlled experiments with the RetinaNet (Lin et al., 2017) framework on the COCO detection task. The results are shown in Table 13. In the standard $1 \\times$ schedule, PEG improves PVT-tiny by $2 . 0 \\%$ mAP. PEG brings $2 . 4 \\%$ higher mAP under the $3 \\times$ schedule. ",
"bbox": [
174,
867,
825,
922
],
"page_idx": 14
},
{
"type": "table",
"img_path": "images/6a5c348be4de1f0ebc180f4d83f11cd2431597c4136565afdef8f00598fb7f96.jpg",
"table_caption": [
"Table 13. Our method boosts the performance of PVT on ImageNet classification, ADE20K segmentation and COCO detection "
],
"table_footnote": [],
"table_body": "<table><tr><td rowspan=\"2\">Backbone</td><td colspan=\"2\">ImageNet</td><td colspan=\"2\">Semantic FPN on ADE20K</td><td colspan=\"3\">RetinaNet on COCO</td></tr><tr><td>Params (M)</td><td>Top-1 (%)</td><td>Params (M)</td><td>mIoU (%)</td><td>Params (M)</td><td>mAP (%,1x)</td><td>mAP (%,3×,+MS)</td></tr><tr><td>ResNet-18 (He et al.,2016)</td><td>12</td><td>69.8</td><td>16</td><td>32.9</td><td>21</td><td>31.8</td><td>35.4</td></tr><tr><td>PVT-tiny (Wang et al., 2021)</td><td>13</td><td>75.0</td><td>17</td><td>35.7</td><td>23</td><td>36.7</td><td>39.4</td></tr><tr><td>PVT-tiny+PEG</td><td>13</td><td>77.3</td><td>17</td><td>38.0</td><td>23</td><td>38.0</td><td>41.8</td></tr><tr><td>PVT-tiny+GAP</td><td>13</td><td>75.9</td><td>17</td><td>36.0</td><td>23</td><td>36.9</td><td>39.7</td></tr><tr><td>PVT-tiny+PEG+GAP</td><td>13</td><td>78.1</td><td>17</td><td>38.8</td><td>23</td><td>38.7</td><td>41.8</td></tr><tr><td>PVT-small (Wang et al., 2021)</td><td>25</td><td>79.8</td><td>28</td><td>39.8</td><td>34</td><td>40.4</td><td>42.2</td></tr><tr><td>PVT-small+PEG+GAP</td><td>25</td><td>81.2</td><td>28</td><td>44.3</td><td>34</td><td>43.0</td><td>45.2</td></tr><tr><td>PVT-Medium (Wang et al.,2021)</td><td>44</td><td>81.2</td><td>48</td><td>41.6</td><td>54</td><td>41.9</td><td>43.2</td></tr><tr><td>PVT-Medium+PEG+GAP</td><td>44</td><td>82.7</td><td>48</td><td>44.9</td><td>54</td><td>44.3</td><td>46.4</td></tr></table>",
"bbox": [
179,
147,
820,
304
],
"page_idx": 15
},
{
"type": "text",
"text": "B.7 ABLATION ON OTHER FORMS OF PEG ",
"text_level": 1,
"bbox": [
176,
333,
483,
348
],
"page_idx": 15
},
{
"type": "text",
"text": "We explore several forms of PEG based on the tiny model, which change the type of convolution, kernel size and layers. The inserted position is 0. The result is shown in Table 14. When we use large kernel of $7 \\times 7$ or dense convolution, the performance improvement is limited. Stacking more layers of depth-wise convolution doesn’t bring significant improvement. Therefore, we use the simplest form as our default implementation. It indicates that this design is enough to provide good position information. ",
"bbox": [
174,
359,
825,
443
],
"page_idx": 15
},
{
"type": "table",
"img_path": "images/79c2a82a8142ebff0f5c8f234ade0e15387f8b272764352eb9d76ada50cb3a0e.jpg",
"table_caption": [
"Table 14. Other forms of PEG. The simple form of a single depth-wise $3 \\times 3$ is good enough. "
],
"table_footnote": [],
"table_body": "<table><tr><td>Variants</td><td>Model</td><td>Top-1 Acc (%)</td></tr><tr><td>1 Depthwise Conv 3×3</td><td>tiny</td><td>72.4</td></tr><tr><td>1 Depthwise Conv 7×7</td><td>tiny</td><td>72.5</td></tr><tr><td>4 *(Depthwise Conv 3×3+BN+ReLU)</td><td>tiny</td><td>72.4</td></tr><tr><td>1 Dense Conv 3×3</td><td>tiny</td><td>72.3</td></tr><tr><td>4 * (Dense Conv 3×3+BN+ReLU)</td><td>tiny</td><td>72.5</td></tr></table>",
"bbox": [
300,
484,
696,
565
],
"page_idx": 15
},
{
"type": "text",
"text": "C EXAMPLE CODE ",
"text_level": 1,
"bbox": [
174,
599,
346,
617
],
"page_idx": 15
},
{
"type": "text",
"text": "C.1 PEG ",
"text_level": 1,
"bbox": [
174,
631,
251,
646
],
"page_idx": 15
},
{
"type": "text",
"text": "In the simplest form, we use a single depth-wise convolution and show its usage in Transformer by the following PyTorch snippet. Through experiments, we find that such a simple design (i.e., depthwise $3 \\times 3$ ) readily achieves on par or even better performance than the recent SOTAs. We give the torch implementation example in Alg. 1. ",
"bbox": [
174,
657,
825,
714
],
"page_idx": 15
},
{
"type": "text",
"text": "D MORE DISCUSSIONS ",
"text_level": 1,
"bbox": [
176,
733,
379,
750
],
"page_idx": 15
},
{
"type": "text",
"text": "D.1 WHY RPE WORKS LESS WELL THAN ABSOLUTE PE? ",
"text_level": 1,
"bbox": [
174,
765,
583,
779
],
"page_idx": 15
},
{
"type": "text",
"text": "As mentioned in Section 5.3 (main text), RPE is inferior to the absolute positional encoding. It is because RPE does not encode any absolute position information. Also discussed in Section B.3 (main text), absolute position information is also important even for ImageNet classification as it is needed to determine which object is at the center of the image. Note that there might be multiple objects in an image, and the label of an image is the category of the object at the center. ",
"bbox": [
174,
790,
825,
861
],
"page_idx": 15
},
{
"type": "text",
"text": "Additionally, although RPE becomes popular recently, it is often jointly used with absolute positional encodings (e.g., in ConViT (d’Ascoli et al., 2021)), or the absolute position information is leaked in other ways (e.g., convolution paddings in CoAtNet (Dai et al., 2021)). This further suggests absolute position information is crucial. ",
"bbox": [
176,
867,
823,
924
],
"page_idx": 15
},
{
"type": "text",
"text": "Algorithm 1 PyTorch snippet of PEG. ",
"text_level": 1,
"bbox": [
176,
103,
426,
118
],
"page_idx": 16
},
{
"type": "text",
"text": "import torch \nimport torch.nn as nn \nclass VisionTransformer: def __init__(layer $_ { \\mathrm { S } } = 1 2$ , ${ \\mathrm { d i m } } { = } 1 9 2$ , nhead $^ { \\underline { { { \\textstyle \\dag } } } } = 3$ , img_size $_ { : = 2 2 4 }$ , patch_size=16): self.pos_block $=$ PEG(dim) self.blocks $=$ nn.ModuleList([TransformerEncoderLayer(dim, nhead, dim $\\mathbf { \\nabla } _ { \\cdot } \\star \\mathbf { \\nabla } _ { \\cdot }$ 4) for _ in range( layers)]) self.patch_embed $=$ PatchEmbed(img_size, patch_size, dim\\*4) def forward_features(self, $\\mathbf { x } )$ ): B, C, H, $W ~ = ~ \\mathrm { ~ x ~ }$ .shape x, patch_size $=$ self.patch_embed(x) _H, $\\_ \\mathrm { ~ \\tt ~ H ~ } = \\mathrm { ~ \\tt ~ H ~ }$ // patch_size, W // patch_size $\\qquad \\times \\quad =$ torch.cat((self.cls_tokens, x), dim $^ { = 1 }$ ) for i, blk in enumerate(self.blocks): x = blk $( \\times )$ if i $\\quad . = = 0$ : $\\times \\quad =$ self.pos_block(x, _H, _W) return x[:, 0] \nclass PEG(nn.Module): def _init__(self, dim $^ { 1 = 2 }$ \\textsc{56}, $\\mathrm { k } = 3$ ): self.pos $=$ nn.Conv2d(dim, dim, k, 1, k//2, groups $=$ dim) # Only for demo use, more complicated functions are effective too. def forward(self, x, H, W): B, N, ${ \\mathrm { ~ \\small ~ \\mathscr ~ { ~ C ~ } ~ } } = { \\mathrm { ~ \\small ~ x ~ } }$ .shape cls_token, feat_tokens $=$ x[:, 0], x[:, 1:] feat_tokens $=$ feat_tokens.transpose(1, 2).view(B, C, H, W) $\\qquad \\times \\quad =$ self.pos(feat_tokens) $^ +$ feat_tokens $\\qquad \\times \\quad =$ x.flatten(2).transpose(1, 2) $\\qquad \\times \\quad =$ torch.cat((cls_token.unsqueeze(1), x), dim=1) return x ",
"bbox": [
173,
131,
813,
426
],
"page_idx": 16
},
{
"type": "text",
"text": "D.2 COMPARISON TO LAMBDA NETWORKS ",
"text_level": 1,
"bbox": [
178,
462,
486,
476
],
"page_idx": 16
},
{
"type": "text",
"text": "Our work is also related to Lambda Networks (Bello, 2021) which uses 2D relative positional encodings. We evaluate its lambda module with an embedding size of 128, where we denote its encoding scheme as RPE2D-d128. Noticeably, this configuration has about 5.9M parameters (comparable to DeiT-tiny) but only obtains $6 8 . 7 \\%$ . We attribute its failure to the limited ability in capturing the correct positional information. After all, lambda layers are designed with the help of many CNN backbones components such as down-sampling to form various stages, to replace ordinary convolutions in ResNet (He et al., 2016). In contrast, CPVT is transformer-based. ",
"bbox": [
174,
489,
825,
587
],
"page_idx": 16
},
{
"type": "text",
"text": "D.3 QUALITATIVE ANALYSIS OF CPVT ",
"text_level": 1,
"bbox": [
178,
609,
460,
623
],
"page_idx": 16
},
{
"type": "text",
"text": "Thus far, we have shown that PEG can have better performance than the original positional encodings. However, because PEG provides the position in an implicit way, it is interesting to see if PEG can indeed provide the position information as the original positional encodings. Here we investigate this by visualizing the attention weights of the transformers. Specifically, given a $2 2 4 \\times 2 2 4$ image (i.e. $1 4 \\times 1 4$ patches), the score matrix within a single head is $1 9 6 \\times 1 9 6$ . We visualize the normalized self-attention score matrix of the second encoder block. ",
"bbox": [
174,
637,
825,
720
],
"page_idx": 16
},
{
"type": "text",
"text": "We first visualize the attention weights of DeiT with the original positional encodings. As shown in Figure 5 (middle), the diagonal element interacts strongly with its local neighbors but weakly with those far-away elements, which suggests that DeiT with the original positional encodings learn to attend the local neighbors of each patch. After the positional encodings are removed (denoted by DeiT w/o PE), all the patches produce similar attention weights and fail to attend to the patches near themselves, see Figure 5 (left). ",
"bbox": [
174,
728,
825,
813
],
"page_idx": 16
},
{
"type": "text",
"text": "Finally, we show the attention weights of our CPVT model with PEG. As shown in Figure 5 (right), like the original positional encodings, the model with PEG can also learn a similar attention pattern, which indicates that the proposed PEG can provide the position information as well. ",
"bbox": [
174,
819,
823,
861
],
"page_idx": 16
},
{
"type": "text",
"text": "We illustrate the attention scores in several encoder blocks of DeiT (Touvron et al., 2020) and CPVT in the Fig. 6. It shows both methods learn similar locality patterns. As attention scores are computed over the tokens projected in different subspaces (Q and K), they do not necessarily show a strict diagonal pattern, where some may have slight shift, see DeiT in Fig. 6c and CPVT of Fig. 5 right. ",
"bbox": [
174,
867,
823,
924
],
"page_idx": 16
},
{
"type": "image",
"img_path": "images/19c1477edf28cf26db81ecd53fd8947ea0edbe4a9868e6368aab289ef778d7ce.jpg",
"image_caption": [
"Figure 5. Normalized attention scores (first head) of the second encoder block of DeiT without position encoding (DeiT w/o PE), DeiT (Touvron et al., 2020), and CPVT on the same input sequence. Position encodings are key to developing a schema of locality in lower layers of DeiT. Meantime, CPVT profits from conditional encodings and follows a similar locality pattern. "
],
"image_footnote": [],
"bbox": [
253,
102,
743,
210
],
"page_idx": 17
},
{
"type": "image",
"img_path": "images/0a11531d79480ac414e128993ffaedb8cbf0d456688b90d3ed26f02be66c7b97.jpg",
"image_caption": [
"Figure 6. Normalized attention scores (the second and third head) of the second and third encoder block of DeiT (Touvron et al., 2020), and CPVT on the same input sequence. DeiT and CPVT share similar locality patterns that are aligned diagonally (some might shift). "
],
"image_footnote": [],
"bbox": [
187,
296,
787,
529
],
"page_idx": 17
},
{
"type": "text",
"text": "D.4 COMPARISON WITH OTHER APPROACHES",
"text_level": 1,
"bbox": [
174,
611,
504,
625
],
"page_idx": 17
},
{
"type": "text",
"text": "We further compare our method with other approaches such as CvT (Wu et al., 2021), ConViT (d’Ascoli et al., 2021) and CoAtNet (Dai et al., 2021) on ImageNet validation set in Table 15. To make fair comparisons, we categorize these methods into two groups: plain and pyramid models. Since our models are primarily for plain models, we adapt our methods on two popular pyramid frameworks PVT and Swin. Our CPVT-S-GAP slightly outperforms ConViT-S by $0 . 2 \\%$ with 4M fewer parameters and 0.8G fewer FLOPs. When equipped with pyramid designs, our methods are still comparable to CvT and CoAtNet. ",
"bbox": [
174,
636,
825,
733
],
"page_idx": 17
},
{
"type": "text",
"text": "Comparison with DeiT w/ Convolutional Projection. Note CvT uses a depth-wise convolution in $\\scriptstyle q - k - v$ projection which they call it Convolutional Projection. Instead of using it in all layers, we put only one of such design into DeiT-tiny and train such a model from scratch under strictly controlled settings. We insert it in the position 0 as in our method. The result is shown in Table 16. This CvT-flavored DeiT achieves $7 0 . 6 \\%$ top-1 accuracy on ImageNet validation set, which is lower than ours $( 7 2 . 4 \\% )$ . Note that $q$ -k-v projections in CvT utilize three depthwise convolutions, therefore, this setting has more parameters than ours. This attests the difference of CvT and CPVT, verifying our advantage by learning better position encodings other than inserting them in all layers to have the ability to capture local context and to remove ambiguity in attention. ",
"bbox": [
173,
750,
825,
875
],
"page_idx": 17
},
{
"type": "table",
"img_path": "images/92a0883388c61f8609d4cd2d321d19b1837a9453c336019225ca6e91ff9d7de4.jpg",
"table_caption": [
"Table 15. Performance comparison with other approaches such as CvT (Wu et al., 2021), ConViT (d’Ascoli et al., 2021) and CoAtNet (Dai et al., 2021) on ImageNet validation set. All the models are trained on ImageNet-1k dataset and tested on the validation set using $2 2 4 \\times 2 2 4$ resolution. "
],
"table_footnote": [],
"table_body": "<table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>Type</td><td rowspan=1 colspan=1>Params</td><td rowspan=1 colspan=1>FLOPs</td><td rowspan=1 colspan=1>Top-1 Acc(%)</td></tr><tr><td rowspan=1 colspan=1>DeiT-small (Touvron et al., 2020)ConViT-S (d'Ascoli et al.,2021)CPVT-S-GAP (ours)</td><td rowspan=1 colspan=1>PlainPlainPlain</td><td rowspan=1 colspan=1>22M27M23M</td><td rowspan=1 colspan=1>4.6G5.4G4.6G</td><td rowspan=1 colspan=1>79.981.381.5</td></tr><tr><td rowspan=2 colspan=1>CoAtNet-0 (Dai et al., 2021)CvT-13 (Wu et al., 2021)PVT-small (Wang et al., 2021)PVT-small+PEG+GAPSwin-tiny (Liu et al.,2021)Swin-tiny+PEG+GAP</td><td rowspan=2 colspan=1>PyramidPyramidPyramidPyramidPyramidPyramid</td><td rowspan=1 colspan=1>25M20M25M25M29M</td><td rowspan=1 colspan=1>4.2G4.5G3.8G3.8G4.5G</td><td rowspan=2 colspan=1>81.681.679.881.281.382.3</td></tr><tr><td rowspan=1 colspan=1>29M</td><td rowspan=1 colspan=1>4.5G</td></tr></table>",
"bbox": [
276,
281,
722,
425
],
"page_idx": 18
},
{
"type": "table",
"img_path": "images/5fc96495858a148a2706ce4d6ef25f7ce93fdb93652fb7c2ecf894f53719bf2d.jpg",
"table_caption": [
"Table 16. Comparison with positional encoding in CvT (Wu et al., 2021) on ImageNet validation set. All the models are trained on ImageNet-1k dataset and tested on the validation set using $2 2 4 \\times 2 2 4$ resolution. "
],
"table_footnote": [],
"table_body": "<table><tr><td>Model</td><td>Params</td><td>Insert Position</td><td>Top-1 Acc (%)</td></tr><tr><td>CPVT-Ti DeiT+ Convolutional Projection</td><td>5681320 5685352</td><td>0 0</td><td>72.4 70.6</td></tr></table>",
"bbox": [
284,
741,
714,
795
],
"page_idx": 18
}
] |