diff --git a/run.py b/run.py new file mode 100755 index 0000000..cca990e --- /dev/null +++ b/run.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python3 + +import pickle + + +weights = pickle.load(open("weights.pkl", "rb")) + + diff --git a/train.py b/train.py new file mode 100755 index 0000000..4bbce43 --- /dev/null +++ b/train.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 + +from sklearn.datasets import load_digits +from sklearn.model_selection import train_test_split +from sklearn.neural_network import MLPClassifier +from sklearn.metrics import accuracy_score +import matplotlib.pyplot as plt +import pickle + +digits = load_digits() + +# input +x = digits.images.reshape((len(digits.images), -1)) + +# what the output should be +y = digits.target + +mlp = MLPClassifier(hidden_layer_sizes=(18,), + activation='logistic', + alpha=1e-4, solver='sgd', + tol=1e-4, random_state=1, + learning_rate_init=.1, + verbose=True) + +mlp.fit(x, y) + +fig, axes = plt.subplots(1, 1) +axes.plot(mlp.loss_curve_, 'o-') +axes.set_xlabel("iterations") +axes.set_ylabel("loss") +plt.show() + +pickle.dump(mlp.coefs_, open( 'weights.pkl', 'wb')) diff --git a/weights.pkl b/weights.pkl new file mode 100644 index 0000000..690aacd Binary files /dev/null and b/weights.pkl differ