Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python optimizer.py example optimizer #6

Open
oysteijo opened this issue May 6, 2019 · 0 comments
Open

Python optimizer.py example optimizer #6

oysteijo opened this issue May 6, 2019 · 0 comments
Assignees

Comments

@oysteijo
Copy link
Owner

oysteijo commented May 6, 2019

The optimizer.py code is just an example of how the optimizer may be in a C implementation.
It is indeed work in progress, and this fiel might be deleted in the future.

As an example, here is an interactive session I had with the code:

In [1]: import numpy as np
In [2]: from optimizer import SGD
In [3]: from reference import NeuralNet
In [4]: nn = NeuralNet("../optimizer/initial_weights.npz", "sigmoid, sigmoid", loss="mean_squared_error" )
In [5]: opt = SGD( nn, learning_rate = 0.01 )
In [6]: arr = np.load("../optimizer/contact_training_and_test.npz")
In [7]: train_X, train_Y, val_X, val_Y = tuple((arr[m] for m in arr))
In [8]: for e in range(20):
   ...:     opt.run_epoch(  train_X, train_Y, val_X, val_Y  )
 mean squared error valid:  0.022117715
 mean squared error valid:  0.016992321
 mean squared error valid:  0.01156354
 mean squared error valid:  0.008583443
 mean squared error valid:  0.00779693
 mean squared error valid:  0.0074062655
 mean squared error valid:  0.0071243667
 mean squared error valid:  0.0069057867
 mean squared error valid:  0.006728847
 mean squared error valid:  0.0065795756

... and maybe needless to say, this i considerably slower than the C implementation.

@oysteijo oysteijo self-assigned this May 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant