-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.py
38 lines (30 loc) · 1.29 KB
/
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
31
32
33
34
35
36
37
38
import torch
import torch.nn as nn
import torch.nn.functional as F
class Rl_cnn(nn.Module):
def __int__(self):
super(Rl_cnn, self).__int__()
# define CNN parameters
self.input_dimensions = 1
self.output_size = 300
# convolution layers
self.unigram_conv_layer = nn.Conv1d(in_channels=self.input_dimensions,
out_channels=self.output_size,
kernel_size=1)
self.bigram_conv_layer = nn.Conv1d(in_channels=self.input_dimensions,
out_channels=self.output_size,
kernel_size=2)
self.trigram_conv_layer = nn.Conv1d(in_channels=self.input_dimensions,
out_channels=self.output_size,
kernel_size=3)
# max pooling layers
self.pool_uni = nn.MaxPool1d(kernel_size=1)
self.pool_bi = nn.MaxPool1d(kernel_size=2)
self.pool_tri = nn.MaxPool1d(kernel_size=3)
# fully connected later
# TODO:
self.fc = nn.Linear() #################### TODO
def forward(self, x):
x = self.unigram_conv_layer(x)
x = torch.relu(x)
x = self.pool