File size: 604 Bytes
3621f16 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 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
|