Vision Transformers have achieved state-of-the-art performance in a wide range of computer vision tasks, but their practical deployment is limited by high computational and memory costs. In this paper, we introduce a novel tensor-based framework for Vision Transformers built upon the Tensor Cosine Product (Cproduct). By exploiting multilinear structures inherent in image data and the orthogonality of cosine transforms, the proposed approach enables efficient attention mechanisms and structured feature representations. We develop the theoretical foundations of the tensor cosine product, analyze its algebraic properties, and integrate it into a new Cproduct-based Vision Transformer architecture (TCP-ViT). Numerical experiments on standard classification and segmentation benchmarks demonstrate that the proposed method achieves a uniform 1/C parameter reduction (where C is the number of channels) while maintaining competitive accuracy.
Figures & tables
Symbol
Description
Himg,Wimg
Image height and width
C
Number of image channels (tube dimension)
P
Patch side length
N=HimgWimg/P2
Number of patches (tokens)
d=P2
Spatial embedding dimension per frontal slice
deff=d⋅C
Effective (flattened) embedding dimension
Table 1: Summary of notation used throughout the paper.
Projection
TCP-ViT weight tensor
Std-ViT weight matrix
WQ,h
Rd×dh×C
RdC×dhC
WK,h
Rd×dh×C
RdC×dhC
WV,h
Rd×dh×C
RdC×dhC
WO
Rd×d×C
RdC×dC
Table 2: MHSA weight dimensions. Each projection is listed per head; the total count sums over all H heads.
Projection
TCP-ViT weight tensor
Std-ViT weight matrix
W1
Rd×dff×C
RdC×dffC
W2
Rdff×d×C
RdffC×dC
Table 3: FFN weight dimensions for TCP-ViT and standard ViT.
Component
TCP-ViT tensor size
TCP-ViT params
Std params
Ratio
WQ,h ( ×H )
Rd×dh×C
d2C
d2C2
1/C
WK,h ( ×H )
Rd×dh×C
d2C
d2C2
1/C
WV,h ( ×H )
Rd×dh×C
d2C
d2C2
1/C
WO
Rd×d×C
d2C
d2C2
1/C
MHSA total
—
4d2C
4d2C2
1/C
W1
Rd×dff×C
rffd2C
rffd2C2
1/C
Table 4: Per-layer parameter comparison between TCP-ViT and standard ViT. Input tensor X∈RN×d×C , standard input X∈RN×dC . Expansion ratio rff , H heads, dh=d/H , dff=rffd .
Dataset
Std-ViT (%)
TCP-ViT (%)
Δ
Std Params
TCP-ViT Params
CIFAR-10
61.8
63.6
+1.8
119,194
43,114
SVHN
49.8
63.8
+14.0
119,194
43,114
STL-10
52.5
55.9
+3.4
119,194
43,114
Parameter ratio
0.362× (theoretical: 0.333× )
Table 5: Classification accuracy on subsampled datasets (10K train / 2K test). TCP-ViT uses 0.362× the parameters of Std-ViT (theoretical: 1/C=0.333× ).
Dataset
Std-ViT (%)
TCP-ViT (%)
Δ
Param ratio
CIFAR-10 (full)
78.7
73.4
−5.3
0.362×
Table 6: Classification accuracy on full CIFAR-10 (50K train / 10K test, 200 epochs). TCP-ViT retains 93.3% of performance with 36.2% of the parameters.
Component
Std-ViT
TCP-ViT
Ratio
Total
1,570,978
751,586
0.478×
Backbone
1,275,072
455,680
0.357×
Transformer Encoder(s)
1,188,480
402,048
0.338×
Embeddings & Tokens
86,592
53,632
0.619×
CNN Decoder
295,906
295,906
1.000×
Table 7: Parameter breakdown for segmentation. The Transformer encoder achieves 0.338× , closely matching the theoretical 1/C=0.333× .
Fig. 1: Parameter distribution. (a) Total parameters: TCP-ViT uses 0.478× of Std-ViT. (b) Stacked breakdown. (c) Component-level comparison.
Metric
Std-ViT
TCP-ViT
Δ
mIoU (%)
87.8
86.8
−1.0
mDice (%)
93.5
92.9
−0.6
Pixel Acc. (%)
94.2
93.6
−0.6
IoU: Background
84.0
82.7
−1.3
IoU: Foreground (Pet)
91.7
90.9
−0.8
Dice: Background
91.3
90.5
−0.8
Table 8: Segmentation performance on Oxford-IIIT Pet. TCP-ViT retains 98.9% of the mIoU with 2.09× fewer parameters. Δ denotes the absolute difference (TCP-ViT − Std-ViT).
Fig. 2: Training dynamics. (a) Training loss, (b) validation loss, (c) mIoU. TCP-ViT (blue) closely tracks Std-ViT (red) with a stable ∼1% gap.
Fig. 3: Normalized confusion matrices. Both models show strong diagonal dominance.
Fig. 4: Qualitative results. Columns: input, ground truth, Std-ViT, TCP-ViT. Green overlay: foreground. Per-image mIoU shown on each prediction.
Fig. 5: Error maps. Green = correct, red = error, gray = ignored. Errors are concentrated at boundaries for both models.
Fig. 6: Efficiency trade-off: parameters vs. mIoU. The dashed arrow indicates the compression direction.