This commit is contained in:
dylodylo 2021-02-03 18:43:43 +01:00
parent cf3569c260
commit 03142695d6
4 changed files with 423140 additions and 598 deletions

135682
dev-0/out.tsv

File diff suppressed because it is too large Load Diff

155042
dev-1/out.tsv

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@ import numpy as np
import csv
class LogisticRegression(torch.nn.Module):
def __init__(self):
def __init__(self, WORDS_IN_DICTIONARY):
super(LogisticRegression, self).__init__()
self.linear = torch.nn.Linear(WORDS_IN_DICTIONARY, 2)
def forward(self, x):
@ -20,7 +20,7 @@ def make_vector(sentence, dictionary):
return vector.view(1, -1)
def read_data(path):
line = open(path, 'r').readlines()[0:2000]
line = open(path, 'r').readlines()[0:1000]
data = []
for word in line:
data.append(word.split())
@ -28,13 +28,17 @@ def read_data(path):
def main():
train_data = read_data("train/in.tsv")
temp = open('train/expected.tsv', 'r').readlines()[0:2000]
temp = open('train/expected.tsv', 'r').readlines()[0:1000]
train_data_output = []
for sent in temp:
train_data_output.append(int(sent))
test_data = read_data('test-A/in.tsv')
output = open('test-A/out.tsv', 'w')
lines = open('dev-0/in.tsv', 'r').readlines()
test_data = []
for line in lines:
test_data.append(line.split())
output = open('dev-0/out.tsv', 'w')
dictionary = {}
@ -45,7 +49,7 @@ def main():
WORDS_IN_DICTIONARY = len(dictionary)
model = LogisticRegression()
model = LogisticRegression(WORDS_IN_DICTIONARY)
criterion = nn.NLLLoss()
optimizer = optim.SGD(model.parameters(), lr=0.1)

File diff suppressed because it is too large Load Diff