test 3
This commit is contained in:
parent
bf33351acc
commit
5ec1581437
1394
dev-0/out.tsv
1394
dev-0/out.tsv
File diff suppressed because it is too large
Load Diff
13
run.py
13
run.py
@ -1,6 +1,8 @@
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
from gensim.models import KeyedVectors
|
from gensim.models import KeyedVectors
|
||||||
|
from sklearn.model_selection import train_test_split
|
||||||
import tensorflow as tf
|
import tensorflow as tf
|
||||||
|
from keras.optimizers import Adam
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
@ -41,6 +43,10 @@ def main():
|
|||||||
[text_to_vector(text, word2vec, vector_size) for text in test_A_dataset["Text"]]
|
[text_to_vector(text, word2vec, vector_size) for text in test_A_dataset["Text"]]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
train_vectors, val_vectors, train_labels, val_labels = train_test_split(
|
||||||
|
train_vectors, train_dataset["Class"], test_size=0.1, random_state=42
|
||||||
|
)
|
||||||
|
|
||||||
# Train a simple neural network
|
# Train a simple neural network
|
||||||
model = tf.keras.Sequential(
|
model = tf.keras.Sequential(
|
||||||
[
|
[
|
||||||
@ -52,15 +58,16 @@ def main():
|
|||||||
)
|
)
|
||||||
|
|
||||||
model.compile(
|
model.compile(
|
||||||
optimizer="adam",
|
optimizer=Adam(learning_rate=1e-3),
|
||||||
loss="binary_crossentropy",
|
loss="binary_crossentropy",
|
||||||
metrics=["accuracy"],
|
metrics=["accuracy"],
|
||||||
)
|
)
|
||||||
|
|
||||||
model.fit(
|
model.fit(
|
||||||
train_vectors,
|
train_vectors,
|
||||||
train_dataset["Class"],
|
train_labels,
|
||||||
epochs=10,
|
validation_data=(val_vectors, val_labels),
|
||||||
|
epochs=30,
|
||||||
batch_size=16,
|
batch_size=16,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
1312
test-A/out.tsv
1312
test-A/out.tsv
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user