forked from alexweav/Learny-McLearnface
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
62 lines (45 loc) · 1.37 KB
/
main.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# -*- coding: utf-8 -*-
"""
Created on Fri May 06 17:56:07 2016
@author: Alexander Weaver
"""
"""
This is an executable script used purely for experimentation.
"""
import numpy as np
import LearnyMcLearnface as lml
def main():
X_train, y_train, X_test, y_test = lml.utils.get_mnist()
data = {
'X_train' : X_train,
'y_train' : y_train,
'X_val' : X_test,
'y_val' : y_test
}
for i in range(10):
pass
opts = {
'input_dim' : 28*28,
'init_scheme' : 'xavier'
}
nn = lml.NeuralNetwork(opts)
nn.add_layer('Affine', {'neurons':600})
nn.add_layer('Batchnorm', {'decay':0.9})
nn.add_layer('PReLU', {})
nn.add_layer('Affine', {'neurons':300})
nn.add_layer('Batchnorm', {'decay':0.9})
nn.add_layer('PReLU', {})
nn.add_layer('Affine', {'neurons':10})
nn.add_layer('SoftmaxLoss', {})
opts = {
'update_options' : {'update_rule' : 'adam', 'learning_rate' : 1e-3, 'beta1' : 0.9, 'beta2' : 0.999},
'reg_param' : 1e-8,
'num_epochs' : 2
}
trainer = lml.Trainer(nn, data, opts)
accuracy = trainer.accuracy(X_test, y_test)
print('Initial model accuracy:', accuracy)
trainer.train()
accuracy = trainer.accuracy(X_test, y_test)
print('Final model accuracy:', accuracy)
main()