FinMM-Project-FinMM / src /models /model_linear.py
GoldenGrapeGentleman1's picture
Upload Project_FinMM before machine wipe
3621f16 verified
Raw History Blame Contribute Delete
604 Bytes
import torch
import torch.nn as nn
class LinearBaseline(nn.Module):
"""
Linear Baseline Model: Simple linear mapping.
"""
def __init__(self, configs):
super().__init__()
self.pred_len = configs.pred_len
self.channels = configs.c_in
# Simple linear predictor
self.linear = nn.Linear(configs.history_len, configs.pred_len)
def forward(self, x):
# x: [B, SeqLen, C] -> [B, C, SeqLen] -> [B, C, PredLen] -> [B, PredLen, C]
x = x.permute(0, 2, 1)
out = self.linear(x)
out = out.permute(0, 2, 1)
return out