-
Notifications
You must be signed in to change notification settings - Fork 7
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
Include evolutionary-keras #737
base: master
Are you sure you want to change the base?
Conversation
9a759db
to
8d68492
Compare
@RoyStegeman let's wait a few weeks for finishing this, once I finish with the optimization of the n3fit it should be more robust for the implementation. |
Sure, just give me heads up by the time you would like to finish this. |
8d68492
to
3b7ef74
Compare
9b4e1e6
to
65e2906
Compare
@scarlehoff I am planning to bring this PR up again next Wednesday as we're at a point where we can (if we want) include this. The macOS test fails at build though and, unless building is just slow and it is ended early due to the time limit, the error is not very enlightening. I heard problems with macOS are not uncommon, so do you perhaps understand this error? |
Yes, the tensorflow package for mac is set to 2.0 because the conda packagers are not able to make anything beyond 2.0 work in Mac :__ (so conda is not able to get around the dependences so it freezes) |
As mentioned in the phone call this can be a good compromise solution where other backends can easily be implemented without permeating to the default conda package. If people like this solution I'll do it proper (mainly: moving things away from @RoyStegeman I've created a "Basic_nga.yml" runcard, but could you put there the entries from one of the actual runcard you use? thanks! How it works: I like because it is clean and clear and as long as backend are tensorflow-dependent this is perfectly fine. |
I adjusted the runcard as you asked. Previously I hadn't included the optimizer parameters since evolutionary-keras's default parameters are in agreement with the once originally used by NNPDF and wanted to prevent cluttering as much as possible. But now that there's a separate file anyway I added the option to set those as well. I like your solution, but if I remember correctly I suggested adding an option to the runcard with an if statement somewhere during the meeting which was not well received. Although maybe Zahari will be able to live with this solution, I guess we'll find out next Wednesday. |
I think the problem people had was having the dependence and not the runcard option. |
Ok, this is ready. @RoyStegeman please have a look and check the docs if you want to add more stuff. @Zaharid since I'm going the responsible user way I would be more comfortable if you have a look at this |
In the end this is a bit more than four lines... |
I suppose the main question is why is there so much complicated global state instead of classes? ITSTM the whole complicated |
To have the option to select backend you have to have more than 4 lines, of course.
If you are talking about |
A possible alternative approach is to have a class and a bunch of top level functions working with an instance of the default class. E.g. https://docs.python.org/3/library/pickle.html#module-pickle However I'd say a bunch of context dependent imports is bringing in way too many footguns. |
I think having more than one backend means having context dependent imports. So, to me the nice thing of these approach is that adding new backends is easy (you only need to add a In this sense I think both
I'm reading through the |
Yes in the sense that some module may or may not be imported, not in the sense that there is some spooky action at a distance that is very difficult to understand by reading the affected module itself. I am not aware of plugin systems that engage in this level of black magic (and would question we want it given just this one instance of plugin). I wish the code looked more like:
where backbend has all the functionality that varies.
There is the class |
The way Keras used to do this was with environment variables so that at first instantiation you get the one backend and that's it.
Then you cannot do |
I'm going to cc @wilsonmr |
742cfe4
to
5a8d358
Compare
Rebased from master to get the fix for travis. So in the end what do you guys prefer, a environment variable that selects the backend (and then by default you have tensorflow) or the ability to change the backend on the go? The advantage of the first is that you don't have context dependent imports more than you already have (not anymore, but until version 2.3 we had a context dependent import since the environment variable The advantage of the second is that in most cases (both this PR and also some other projects I am working on) the "other backends" are actually extensions on top of TensorFlow so developing wise I like having a function that changes all the imports but I realise why people wouldn't like this. Edit: I favour now the second scenario since it is much cleaner when building a chain of backends (which I have in a personal project, where backend C extends B which extends tensorflow) |
I was CCed but I feel a bit out of my depth here. I think the function which changes the imports seems reasonable enough but I don't really know what the potential hazards are with these things. |
Honestly, I don't feel like I have sufficient familiarity with code development to make this choice. At best I can try and weight the arguments you've provided, so it's probably best to aks input from e.g. Stefano if you need a deciding vote... |
kept as a draft for now until a third backend is added |
5a8d358
to
ed88b30
Compare
@RoyStegeman if you don't mind I'll keep rebasing this branch periodically to the current master because I want to keep it up to date. |
Of course, please feel free to. |
@scarlehoff do you still have plans for this PR? I think the other backend you were considering was for the quantum computer project, but apparently that didn't end up getting added. |
it was, in a "secret" repo, but having this (and any other) available in a way that makes people happy (including myself) is more work than it is worth it |
I see. So is there a reason not to close this? |
It is a working version so if someone is really interested they can run fits with |
That's true, although that specific functionality can also be obtained very minimally by inhering the evolutionary keras model instead of the regular keras |
The machinery is needed for a more general "choose your backend" scenario. I would leave it open because maybe in a few years time it is useful to some unsuspecting student. If it is closed it will never be found (and we will never get to a 0-issues, 0-PRs scenario) But I very much doubt it will be ever be used again so if it's closed I'm also ok with it. |
Sure, it can be left open, I don't care much either way but since the last thing I heard was that you were planning to add another backend which didn't happen, I just wanted to make sure it was a conscious decision not to close this. |
This branch contains the same commits as
n3fit-nnfit_in_n3fit
, but is instead rebased to the current point of master, while we want to preserven3fit-nnfit_in_n3fit
for future reference as this is the branch used to do the test with the NGA and CMA-ES.Once n3fit has been optimized and TF2.2 released, this branch can be merged.