-
Notifications
You must be signed in to change notification settings - Fork 0
/
Model.py
30 lines (25 loc) · 798 Bytes
/
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
25
26
27
28
29
30
import torch
import torch.autograd as autograd
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.autograd import Variable
class Model(nn.Module):
def __init__(self, config):
super(Model, self).__init__()
self.config = config
self.batch_h = None
self.batch_t = None
self.batch_r = None
self.batch_y = None
def get_positive_score(self, score):
return score[0:self.config.batch_size]
def get_negative_score(self, score):
negative_score = score[self.config.batch_size:self.config.batch_seq_size]
negative_score = negative_score.view(-1, self.config.batch_size)
negative_score = torch.mean(negative_score, 0)
return negative_score
def forward(self):
raise NotImplementedError
def predict(self):
raise NotImplementedError