-
Notifications
You must be signed in to change notification settings - Fork 39
/
example_theano.py
31 lines (17 loc) · 857 Bytes
/
example_theano.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import numpy as np
from sklearn.datasets import make_classification, make_regression
from neural_network_theano.layer_classes import fully_connected_layer, convolutional_layer
from neural_network_theano.neural_network import NeuralNetworkClassifier, NeuralNetworkRegressor
np.random.seed(0)
# Classification
X, y = make_classification(1000, 64, n_informative=10, n_classes=5)
layers = [convolutional_layer()]
nn = NeuralNetworkClassifier(layers=layers, batch_size=1000, max_epochs=300, learning_rate=1e-4, verbose=True)
nn.fit(X, y)
print "Classification Score %.8f" % nn.score(X, y)
# Regression
X, y = make_regression(1000, 50)
layers = [fully_connected_layer(n_hidden=30)]
nn = NeuralNetworkRegressor(layers=layers, batch_size=10, max_epochs=20, learning_rate=1e-4, verbose=True)
nn.fit(X, y)
print "Regression Score %.8f" % nn.score(X, y)