File size: 1,118 Bytes
3621f16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
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