aboutsummaryrefslogtreecommitdiffstats
path: root/dlstuff/two.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xdlstuff/two.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/dlstuff/two.py b/dlstuff/two.py
index 9eab134..8287708 100755
--- a/dlstuff/two.py
+++ b/dlstuff/two.py
@@ -10,6 +10,7 @@ from keras.datasets import imdb
import numpy as np
from keras import models
from keras import layers
+from keras import regularizers
import matplotlib.pyplot as plt
def SigHandler_SIGINT(signum, frame):
@@ -67,8 +68,10 @@ def premain(argparser):
y_test = np.asarray(test_labels).astype("float32")
model = models.Sequential()
- model.add(layers.Dense(16, activation="relu", input_shape=(10000,)))
- model.add(layers.Dense(16, activation="relu"))
+ model.add(layers.Dense(16, kernel_regularizer=regularizers.l2(0.001), activation="relu", input_shape=(10000,)))
+ model.add(layers.Dropout(0.5))
+ model.add(layers.Dense(16, kernel_regularizer=regularizers.l2(0.001), activation="relu"))
+ model.add(layers.Dropout(0.5))
model.add(layers.Dense(1, activation="sigmoid"))
x_val = x_train[:10000]
@@ -85,7 +88,7 @@ def premain(argparser):
plot_acc(history)
'''
- model.fit(x_train, y_train, epochs=4, batch_size=512)
+ model.fit(x_train, y_train, epochs=20, batch_size=512)
results = model.evaluate(x_test, y_test)
print(results)