Compare commits

...

4 Commits

Author SHA1 Message Date
b8a409e014 weszlo 2021-05-13 22:06:31 +02:00
7616b2d9f5 test 2021-05-13 21:05:06 +02:00
Jakub
4388b7d18d wynik 2021-05-08 12:54:53 +02:00
5e66be7f46 dziala 2021-05-08 12:51:14 +02:00
7 changed files with 310492 additions and 0 deletions

5272
dev-0/in.tsv Normal file

File diff suppressed because one or more lines are too long

5272
dev-0/out.tsv Normal file

File diff suppressed because it is too large Load Diff

BIN
geval Executable file

Binary file not shown.

65
main.py Normal file
View File

@ -0,0 +1,65 @@
from gensim.test.utils import common_texts
from gensim.models import Word2Vec
from sklearn import preprocessing
import pandas as pd
import numpy as np
import gensim
import torch
class NeuralNetworkModel(torch.nn.Module):
def __init__(self):
super(NeuralNetworkModel, self).__init__()
self.fc1 = torch.nn.Linear(maxim, 500)
self.fc2 = torch.nn.Linear(500, 1)
def forward(self, x):
x = self.fc1(x)
x = torch.relu(x)
x = self.fc2(x)
x = torch.sigmoid(x)
return x
with open("train/in.tsv") as xd:
x1 = xd.readlines()
with open("train/expected.tsv") as xdd:
y1 = xdd.readlines()
with open("test-A/in.tsv") as xddd:
x = xddd.readlines()
maxim = 500
bLen = 5
exp = Word2Vec(x1, min_count = 1, vector_size = 500, workers = 3, window = 3, sg = 1)
exp1 = Word2Vec(x, min_count = 1, vector_size = 500, workers = 3, window = 3, sg = 1)
exp2 = NeuralNetworkModel()
x1 = exp.wv
x = exp1.wv
crt = torch.nn.BCELoss()
miz = torch.optim.SGD(exp2.parameters(), lr = 0.1)
for each in range(10):
lossScore, accScore, sums = 0
exp2.train()
for i in range(0, y1.shape[0], bLen):
x = x1[i : i + bLen]
x = torch.tensor(x.astype(np.float32).todense())
y = y1[i : i + bLen]
y = torch.tensor(y.astype(np.float32)).reshape(-1, 1)
y2 = exp2(x)
accScore += torch.sum((y2 > 0.5) == y).item()
sums += y.shape[0]
miz.zero_grad()
loss = crt(y2, Y)
loss.backward()
miz.step()
lossScore += loss.item() * Y.shape[0]
with open('test-A/out.tsv', 'w') as file:
for each in y2:
file.write("%f\n" % each)

5152
test-A/in.tsv Normal file

File diff suppressed because one or more lines are too long

5152
test-A/out.tsv Normal file

File diff suppressed because it is too large Load Diff

289579
train/in.tsv Normal file

File diff suppressed because one or more lines are too long