StockformerDualEncoder<T>

Models & Types · AiDotNet.Finance.Trading.Factors

Stockformer’s Dual-Frequency Spatiotemporal Encoder and its fusion decoder, following the paper’s equations rather than the shape of its prose.

For Beginners

The slow and fast parts of each price series are analysed separately, each is allowed to look across the other assets — with a graph embedding telling it which assets are similar — and then the slow view consults the fast one.

How It Works

Ma, Xue, Lu and Chen, arXiv:2401.06139, equations 7, 10 and 11.

Three corrections against an earlier revision of this class, each found by reading the method section rather than only the reference code:

The high band’s temporal operator is a causal convolution rather than attention. Eq. 7 specifies attention for the LOW band only; the reference implementation uses temporalConvNet for the high band, so that choice is justified by the code, not the paper.

Constructors

Constructor Summary
StockformerDualEncoder(int features, int kernelWidth, IReadOnlyList<Layer<T>> layers, StockformerAttention<T> fusionSelf, StockformerAttention<T> fusionCross, ILayer<T> fusionNorm) Creates an encoder over caller-owned layers.

Properties

Property Summary
int Features { get; } Gets the model width.
int LayerCount { get; } Gets the number of stacked encoder layers (L).

Methods

Method Summary
ValueTuple<Tensor<T>, Tensor<T>> Encode(Tensor<T> low, Tensor<T> high, Matrix<T> spatialEmbedding, Matrix<T> temporalEmbedding) Encodes both bands through the stack and fuses them.