  The traditional Transformer model encounters challenges with variable-length
input sequences, particularly in Hyperspectral Image Classification (HSIC),
leading to efficiency and scalability concerns. To overcome this, we propose a
pyramid-based hierarchical transformer (PyFormer). This innovative approach
organizes input data hierarchically into segments, each representing distinct
abstraction levels, thereby enhancing processing efficiency for lengthy
sequences. At each level, a dedicated transformer module is applied,
effectively capturing both local and global context. Spatial and spectral
information flow within the hierarchy facilitates communication and abstraction
propagation. Integration of outputs from different levels culminates in the
final input representation. Experimental results underscore the superiority of
the proposed method over traditional approaches. Additionally, the
incorporation of disjoint samples augments robustness and reliability, thereby
highlighting the potential of our approach in advancing HSIC.
  The source code is available at https://github.com/mahmad00/PyFormer.
