-
Notifications
You must be signed in to change notification settings - Fork 3
/
load_model.py
24 lines (19 loc) · 840 Bytes
/
load_model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from models import LinearModel, LSTMModel, LinearLSTMModel, LSTMModelcopy1, LSTMBertModel
import torch.nn as nn
class Model(nn.Module):
def __init__(self, cfg, args):
super(Model, self).__init__()
self.cfg = cfg
self.args = args
def forward(self):
if self.args.load_model == 'linear':
model = LinearModel(self.cfg, self.args)
elif self.args.load_model == 'lstm':
model = LSTMModel(self.cfg, self.args)
elif self.args.load_model == 'linearlstm':
model = LinearLSTMModel(self.cfg, self.args)
elif self.args.load_model == 'lstmcopy1':
model = LSTMModelcopy1(self.cfg, self.args)
elif self.args.load_model == 'lstmbert':
model = LSTMBertModel(self.cfg, self.args)
return model