Skip to content

Commit f2438a1

Browse files
committed
add sk_mlp
1 parent 365e9e9 commit f2438a1

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

unsupervised_class2/sk_mlp.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# https://deeplearningcourses.com/c/data-science-deep-learning-in-theano-tensorflow
2+
# https://www.udemy.com/data-science-deep-learning-in-theano-tensorflow
3+
from __future__ import print_function, division
4+
from future.utils import iteritems
5+
from builtins import range, input
6+
# Note: you may need to update your version of future
7+
# sudo pip install -U future
8+
9+
10+
import numpy as np
11+
from sklearn.neural_network import MLPRegressor
12+
from util import getKaggleMNIST
13+
14+
15+
16+
# get data
17+
X, _, Xt, _ = getKaggleMNIST()
18+
19+
# create the model and train it
20+
model = MLPRegressor()
21+
model.fit(X, X)
22+
23+
# test the model
24+
print("Train R^2:", model.score(X, X))
25+
print("Test R^2:", model.score(Xt, Xt))
26+
27+
Xhat = model.predict(X)
28+
mse = ((Xhat - X)**2).mean()
29+
print("Train MSE:", mse)
30+
31+
Xhat = model.predict(Xt)
32+
mse = ((Xhat - Xt)**2).mean()
33+
print("Test MSE:", mse)

0 commit comments

Comments
 (0)