improve
This commit is contained in:
parent
cf3569c260
commit
03142695d6
135682
dev-0/out.tsv
135682
dev-0/out.tsv
File diff suppressed because it is too large
Load Diff
155042
dev-1/out.tsv
155042
dev-1/out.tsv
File diff suppressed because it is too large
Load Diff
|
@ -6,7 +6,7 @@ import numpy as np
|
||||||
import csv
|
import csv
|
||||||
|
|
||||||
class LogisticRegression(torch.nn.Module):
|
class LogisticRegression(torch.nn.Module):
|
||||||
def __init__(self):
|
def __init__(self, WORDS_IN_DICTIONARY):
|
||||||
super(LogisticRegression, self).__init__()
|
super(LogisticRegression, self).__init__()
|
||||||
self.linear = torch.nn.Linear(WORDS_IN_DICTIONARY, 2)
|
self.linear = torch.nn.Linear(WORDS_IN_DICTIONARY, 2)
|
||||||
def forward(self, x):
|
def forward(self, x):
|
||||||
|
@ -20,7 +20,7 @@ def make_vector(sentence, dictionary):
|
||||||
return vector.view(1, -1)
|
return vector.view(1, -1)
|
||||||
|
|
||||||
def read_data(path):
|
def read_data(path):
|
||||||
line = open(path, 'r').readlines()[0:2000]
|
line = open(path, 'r').readlines()[0:1000]
|
||||||
data = []
|
data = []
|
||||||
for word in line:
|
for word in line:
|
||||||
data.append(word.split())
|
data.append(word.split())
|
||||||
|
@ -28,13 +28,17 @@ def read_data(path):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
train_data = read_data("train/in.tsv")
|
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 = []
|
train_data_output = []
|
||||||
for sent in temp:
|
for sent in temp:
|
||||||
train_data_output.append(int(sent))
|
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 = {}
|
dictionary = {}
|
||||||
|
@ -45,7 +49,7 @@ def main():
|
||||||
|
|
||||||
WORDS_IN_DICTIONARY = len(dictionary)
|
WORDS_IN_DICTIONARY = len(dictionary)
|
||||||
|
|
||||||
model = LogisticRegression()
|
model = LogisticRegression(WORDS_IN_DICTIONARY)
|
||||||
|
|
||||||
criterion = nn.NLLLoss()
|
criterion = nn.NLLLoss()
|
||||||
optimizer = optim.SGD(model.parameters(), lr=0.1)
|
optimizer = optim.SGD(model.parameters(), lr=0.1)
|
||||||
|
|
132998
test-A/out.tsv
132998
test-A/out.tsv
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue