aboutsummaryrefslogtreecommitdiff
path: root/lenet.py
diff options
context:
space:
mode:
authorVasil Zlatanov <v@skozl.com>2019-02-27 18:32:26 +0000
committerVasil Zlatanov <v@skozl.com>2019-02-27 18:32:26 +0000
commit9c26f3b6e6b317c910bf3bdafc9b070c151dff4a (patch)
tree6fa7bfd01fcb1cd82c7bc4ed31091e8ad9d5a963 /lenet.py
parent7465d4fdde046843cb8bca3b233c2cdd99c39722 (diff)
downloade4-gan-9c26f3b6e6b317c910bf3bdafc9b070c151dff4a.tar.gz
e4-gan-9c26f3b6e6b317c910bf3bdafc9b070c151dff4a.tar.bz2
e4-gan-9c26f3b6e6b317c910bf3bdafc9b070c151dff4a.zip
Add metric sna optimizer arguments
Diffstat (limited to 'lenet.py')
-rw-r--r--lenet.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/lenet.py b/lenet.py
index 8595eb8..d09f3cc 100644
--- a/lenet.py
+++ b/lenet.py
@@ -106,12 +106,14 @@ def plot_history(history, metric = None):
plt.ylabel('Loss')
plt.xlabel('Epoch')
-def train_classifier(x_train, y_train, x_val, y_val, batch_size=128, epochs=100):
+def train_classifier(x_train, y_train, x_val, y_val, batch_size=128, epochs=100, metrics=['categorical_accuracy'], optimizer = None):
shape = (32, 32, 1)
model = get_lenet(shape)
- sgd = optimizers.SGD(lr=0.001, decay=1e-6, momentum=0.9, nesterov=True)
- model.compile(loss='categorical_crossentropy', optimizer=sgd)
+ if optimizer = None:
+ optimizer = optimizers.SGD(lr=0.001, decay=1e-6, momentum=0.9, nesterov=True)
+
+ model.compile(loss='categorical_crossentropy', metrics=metrics, optimizer=optimizer)
history = model.fit(x_train, y_train, batch_size=batch_size, epochs=epochs, verbose=1, validation_data = (x_val, y_val))
plot_history(history)