## 3 Methodology
### Target Alternating Attention  
To aggregate more complete image information, this paper proposes target alternating attention (TAA), which aggregates the pixel contextual information of central pixel points in each surrounding layer according to the target to enhance item features, obtain important information more efficiently, and enhance the integrity and reliability of semantic feature description. Target alternating attention collects pixel contextual information in a hierarchical direction to enhance the pixel-level representation ability. A frame diagram of target alternating attention is shown in Figure 4. Each pixel in the image is traversed from top to bottom and from left to right. For each pixel, the pixel contextual information of the center pixel around the pixel is mined from inside to outside according to the target, until the outermost pixel is traversed, to obtain more accurate recommendation results. The input image is processed by the MCNN to generate the feature map X with space size \(\mathrm{H}\times\mathrm{W}\). Given X, we first apply the convolutional layer to obtain the reduced-dimension feature map \(\mathrm{H}(0)\), and then send the feature map \(\mathrm{H}(0)\) into the target alternating attention. After the first loop, a new feature map \(\mathrm{H}(1)\) is generated, which aggregates the information of the four pixels of upper left, upper right, lower left, and lower right. To obtain richer and denser pixel contextual information, we send the feature map \(\mathrm{H}(1)\) again into the target alternating attention and output feature map \(\mathrm{H}(2)\). This process is repeated R times until the boundary pixel point position of the image, so that each position in the feature map \(\mathrm{H}(\mathrm{R})\) actually collects information from all pixels. Target alternating attention collects information about four pixels per loop. Given the local feature map \(\mathrm{H}(0)\in\mathbb{R}^{\mathrm{C}\times\mathrm{W}\times\mathrm{H}}\), this module firstly applies two convolutional layers with \(1\times 1\) filter to \(\mathrm{H}(0)\) to generate two feature maps, Q and K, where \(\{\mathrm{Q},\mathrm{K}\}\in\mathbb{R}^{\mathrm{C}^{\prime}\times\mathrm{W} \times\mathrm{H}}\). \(\mathrm{C}^{\prime}\) is the number of channels, less than C for dimension reduction. After obtaining the feature maps Q and K, the attention map \(\mathrm{M}\in\mathbb{R}^{2\times(\mathrm{H}+\mathrm{W}-4)\times\mathrm{W} \times\mathrm{H}}\) is further generated through Affinity. At each position u of the spatial dimension of feature map Q, the vector \(\mathrm{Q}_{\mathrm{u}}\in\mathbb{R}^{\mathrm{C}^{\prime}}\) is obtained. At the same time, the set \(\mathrm{\Omega}_{\mathrm{u}}\in\mathbb{R}^{2\times(\mathrm{H}+\mathrm{W}-4) \times\mathrm{C}^{\prime}}\) can be obtained by extracting four feature vectors from K: upper left, upper right, lower left, lower right, or up, down, left, and right on each ring from position u outward. \(\mathrm{\Omega}_{\mathrm{i},\mathrm{u}}\in\mathbb{R}^{\mathrm{C}^{\prime}}\) is the i th element of \(\mathrm{\Omega}_{\mathrm{u}}\). The Affinity operation is defined as follows:  
\[d_{i,u}=\sqrt{(Q_{u}-\mathrm{\Omega}_{i,u})(Q_{u}-\mathrm{\Omega}_{i,u})^{T}} \tag{1}\]  
Figure 4: Structure of target alternating attention. where the \(\rm{d_{i,u}}\in D\) is the feature correlation between \(\rm{Q_{u}}\) and \(\rm{\Omega_{i,u}}\), \(\rm{i}=[1,\ldots,|\rm{\Omega_{u}}|]\), \(\rm{D}\in\mathbb{R}^{2\times(H+W-4)\times W\times H}\). Then, we apply the softmax layer on channel dimension \(\rm{D}\) to calculate the attention map \(\rm{M}\). Another convolutional layer with a 1 \(\times\) 1 filter is applied to \(\rm{H(0)}\) to generate \(\rm{V}\in\mathbb{R}^{C\times W\times H}\) for feature adaptation. At each position \(\rm{u}\) of the spatial dimension in the feature map \(\rm{V}\), we obtain the vector \(\rm{V_{u}}\in\mathbb{R}^{C}\) and a set of \(\rm{\Phi_{u}}\in\mathbb{R}^{2\times(H+W-4)\times C}\).