Download src/models/model_dmmv_as.py from GoldenGrapeGentleman1/FinMM-Project-FinMM: direct link, hf CLI and curl.
- Browser
- Download file 1.12 kB
-
https://huggingface.co/GoldenGrapeGentleman1/FinMM-Project-FinMM/resolve/main/src/models/model_dmmv_as.py
- Command line
-
hf download hf://GoldenGrapeGentleman1/FinMM-Project-FinMM/src/models/model_dmmv_as.py
-
curl -L -o model_dmmv_as.py https://huggingface.co/GoldenGrapeGentleman1/FinMM-Project-FinMM/resolve/main/src/models/model_dmmv_as.py
1.12 kB
| """ | |
| Dual-Modal Fusion: DMMV-A + DMMV-S (without Kronos). | |
| Combines advantages of adaptive decomposition and moving average decomposition. | |
| """ | |
| import torch | |
| import torch.nn as nn | |
| import sys | |
| sys.path.insert(0, '/workspace/dmmv') | |
| from model_dmmv_a import DMMV_A_Wrapper | |
| from model_dmmv_s import DMMV_S_Fixed | |
| class DMMV_AS_Fusion(nn.Module): | |
| """Dual-Modal DMMV Fusion (without Kronos).""" | |
| def __init__(self, configs): | |
| super().__init__() | |
| # DMMV-A Branch: Adaptive Decomposition | |
| self.dmmv_a = DMMV_A_Wrapper(configs) | |
| # DMMV-S Branch: Moving Average Decomposition | |
| self.dmmv_s = DMMV_S_Fixed(configs) | |
| # Simple weighted fusion | |
| self.alpha = nn.Parameter(torch.tensor(0.5)) # Learnable weight | |
| def forward(self, x): | |
| # Predictions from both DMMV branches | |
| pred_a = self.dmmv_a(x) # [B, PredLen, C] | |
| pred_s = self.dmmv_s(x) # [B, PredLen, C] | |
| # Weighted fusion | |
| w = torch.sigmoid(self.alpha) # Range 0-1 | |
| fused = w * pred_a + (1 - w) * pred_s | |
| return fused | |