-
Notifications
You must be signed in to change notification settings - Fork 75
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
Parameter Optimization #433
Conversation
This program finds good parameters for an HTM system.
hey, this is a huge and much welcome contribution! 💯 Sorry, I'll get later to review, even just to read the doc. Some high-level thoughts about parameter optimization/tuning:
|
py/src/nupic/optimization/ae.py
Outdated
ExperimentModule.main(parameters=default_parameters, argv=None, verbose=True) | ||
Returns (float) performance of parameters, to be maximized. | ||
|
||
Usage: $ ae.py [ae-arguments] ExperimentModule.py [experiment-arguments] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you provide a runnable demo example? That would be worth 1000 words for first-timers wishing to use the code.
MNIST would be an ideal candidate and you've already optimized that code for me once, so you should have the "experiment" files ready.
py/src/nupic/optimization/ae.py
Outdated
return best.parameters | ||
|
||
|
||
class GridSearch(object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you need to write the hyper param optimization code yourself? It is available in many toolkits?
https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.GridSearchCV.html
py/src/nupic/optimization/ae.py
Outdated
import tempfile | ||
import multiprocessing | ||
import resource | ||
import signal # Probably not X-platform ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would this be a problem? but hey..worst case, the feature will be avail only for certain OSs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked this up, This use of signal
can be replaced with multithreading.timer which is X-platform.
|
||
from .nupic.optimization.parameter_set import ParameterSet | ||
|
||
class ParticleSwarmOptimizations: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do really like the recent changes! 👏 , extracting the particular search mechanism away, and adding the new PSO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extracting the particular search mechanism away
This turned out to be more problematic than I expected. Each search method needs:
- Command line arguments
- Queue experiments
- Collect results, asynchronously from the queuing them
Currently it can only queue experiments. I'm thinking about how to do all of this in a sane way that allows for new methods to plug-in. I might make a new interface class to help with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you considered the 3rd party for param optimization, model selection? And "just" write enabling interface for our params & constructors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this framework is useful, it's all about sharing trained deep learning networks.
https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.GridSearchCV.html
Scikit learn appears very limited.
- The only search method it has is GridSearch. It does not do swarming.
- I also want the parameter optimization code to save all of the outputs of the program. Which scikitlearn doesn't do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed on NNEF
Scikit learn appears very limited.
it was only a first hit I got from memory, these "python parameter optimization frameworks" look interesting:
https://hyperopt.github.io/hyperopt/
https://optuna.org/
I do like your solution, but in the longrun I hope we'll have an interface to a 3rd party project, as there's lots of details which are out of scope for us (same as Serialization, ..)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have an interface to a 3rd party project, as there's lots of details which are out of scope for us
I understand, I will do some more research into existing solutions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3rd party solutions
I found a great project, it's called nni. It is a framework for optimizing artificial neural networks (the non-biological kind). I read through it and attempted (but ultimately failed) to run the MNIST example with it.
- Its open source (MIT license) so we could easily incorporate it into our project.
- It's run by microsoft, and they appear to be actively developing it. They accept external PR's and they might even fix issues we have with it.
- It is well designed. It's got some neat features too.
All that praise said, I don't think it's ready for mainstream use. It's rough at the edges. The project is about a year old. In a year this could be the defacto standard tool, but today I'd rather keep using my tools which I'm familiar with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found a great project, it's called nni.
I like NNI! although the whole AutoML seems overkill for us (we don't need network architecture "evolution", as we have HTM, we "just" need a way for param optimization.
I read through it and attempted (but ultimately failed) to run the MNIST example with it.
ok, let's go with what you have now. I would suggest not "wasting" time developing too many features, as long term we'd like to switch over to an external framework to do the work for us.
The current will be a great improvement, so let's 👍
PS: what have failed running their mnist? Do you think it's not ready yet, or should I try in some later PR?
Ideally, if you can take their (NNI or other suitable) design in mind, and develop the format for "experiment description" what you call it, similar/same, so we can later easily switch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PS: what have failed running their mnist?
I tried running our MNIST in their framework.
the format for "experiment description"
This is highly dependent on the specifics of the optimization framework.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will push the work i did for NNI in a branch so that you can play with it.
I think the problem i had is that NNI does not start by trying the default parameters. It spent a considerable amount of time trying parameters which obviously wont work. Swarming has an advantage over TPE (the search method nni defaults to) in that it starts near the default parameter values which are at least sane. The NNI framework has a way to end trials/experiments early if they obviously arent working, but i didnt use it.
This is really cool. 🥇 |
While i think thats a good idea, i dont want to deal with the logistics of having two repos and a depenency. Maybe for now we can keep this here, and reconsider the location later when we also reconsider the alternatives? |
I finished my review. The documentation still needs work before this can merge. |
The process pool that comes with python standard library does not always work very well, and does not give the caller enough control to fix problems with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks very good now! 👍
I'm looking forward to using this new feature.
One TODO: I'd like to see an example how this is used on either of hotgym/mnist, if that is not already part of #480 ?
'synPermConnected': 0.422, | ||
'synPermInactiveDec': 0.005 | ||
'boostStrength': 7.80643753517375, | ||
'columnDimensions': (35415,), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OT: I wonder how much the scores differ? It's said HTM is/should be more resistant to param changes. These seem like a rather big difference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC accuracy improved from about 90% to 96%.
self.save() # Write the updated Lab Report to file. | ||
|
||
|
||
class Worker(Process): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, do you want to split some of these to separate classes?
Thanks for reviewing this! |
This program finds good parameters for an HTM system.
I wrote this program a while ago, and now I'd like to contribute it.
This is a large addition, and it is not ready yet. I do not recommend reviewing the code, instead just read the documentation at the top of the file.