Spaces:
Sleeping
Sleeping
Анастасия
commited on
Commit
·
3b29e59
1
Parent(s):
8eaf5b2
- .DS_Store +0 -0
- model/.DS_Store +0 -0
- model/BiLSTM_model.py +21 -0
- model/__pycache__/BiLSTM_model.cpython-310.pyc +0 -0
- model/model_weights.pth +3 -0
.DS_Store
CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
|
|
model/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
model/BiLSTM_model.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
import torch.nn as nn
|
3 |
+
|
4 |
+
class BiLSTM(nn.Module):
|
5 |
+
def __init__(self, input_size, hidden_size, num_layers, output_size):
|
6 |
+
super(BiLSTM, self).__init__()
|
7 |
+
self.hidden_size = hidden_size
|
8 |
+
self.num_layers = num_layers
|
9 |
+
self.lstm = nn.LSTM(input_size, hidden_size, num_layers, batch_first=True, bidirectional=True)
|
10 |
+
self.fc = nn.Linear(hidden_size*2, output_size) # Умножаем на 2 из-за двунаправленности
|
11 |
+
|
12 |
+
def forward(self, x):
|
13 |
+
h0 = torch.zeros(self.num_layers*2, x.size(0), self.hidden_size).to(x.device) # 2 для bidirectional
|
14 |
+
c0 = torch.zeros(self.num_layers*2, x.size(0), self.hidden_size).to(x.device)
|
15 |
+
|
16 |
+
out, _ = self.lstm(x, (h0, c0))
|
17 |
+
out = self.fc(out[:, -1, :])
|
18 |
+
return out
|
19 |
+
|
20 |
+
# device = 'cpu'
|
21 |
+
# model = BiLSTM().to(device)
|
model/__pycache__/BiLSTM_model.cpython-310.pyc
ADDED
Binary file (1.09 kB). View file
|
|
model/model_weights.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e8c52848e24ea2eb6939c13fcd44370e66d222870ca5f3a2497de710f00e824d
|
3 |
+
size 3707994
|