opm-common icon indicating copy to clipboard operation
opm-common copied to clipboard

ML keras

Open bikagit opened this issue 1 year ago • 13 comments

Integrating Keras capabilities to OPM. Draft pull request to test/discuss implications of the changes in OPM. This enables the straightforward and adaptable integration of neural networks into OPM scripts. These models are initially trained using the Keras library in Python, stored in a format readable for the OPM framework and subsequently deployed within OPM. When the user initializes and loads a stored Keras model inside an OPM script, an automated deployment process handles all the translation. This process works by operating a series of steps handling model interpretation, layer conversion, optimization, and code generation steps to adapt the Keras model to a native OPM function.

bikagit avatar Aug 22 '24 12:08 bikagit

jenkins build this please

totto82 avatar Aug 22 '24 13:08 totto82

jenkins build this please

daavid00 avatar Aug 22 '24 13:08 daavid00

This does not add a dependency on a third party library, so then I assume it instead embeds Keras in some way? Or have I misunderstood the purpose of this PR?

atgeirr avatar Aug 22 '24 13:08 atgeirr

Is there a reason this is added to opm-common instead of being a separate repository? Do we, somehow, need to make (selected) objects in this repository, or any of its downstream repositories for that matter, "aware" of Keras?

bska avatar Aug 22 '24 15:08 bska

This does not add a dependency on a third party library, so then I assume it instead embeds Keras in some way? Or have I misunderstood the purpose of this PR?

We use Keras for the training process (it doesnt need to be done in OPM). The generated models are subsequently embedded and run in OPM. I have updated the description to provide some context.

bikagit avatar Aug 22 '24 15:08 bikagit

jenkins build this please

totto82 avatar Aug 26 '24 13:08 totto82

jenkins build this please

daavid00 avatar Aug 28 '24 07:08 daavid00

Maybe I'm missing something, but as far as I can tell no-one have answered my question from last week

Is there a reason this is added to opm-common instead of being a separate repository? Do we, somehow, need to make (selected) objects in this repository, or any of its downstream repositories for that matter, "aware" of Keras?

I would really like an answer to this before I consider the details of the PR.

bska avatar Aug 28 '24 10:08 bska

I would really like an answer to this before I consider the details of the PR.

Sorry for not answering earlier. The idea is to apply the ML-Keras inside OPM for different tasks. This is only the first PR to add the Keras ML model. The applications will follow. For an example of a ML near well model using ML-Keras check out https://github.com/cssr-tools/ML_near_well. Since the ML-Keras model framework is general. We hope it would be useful for the OPM community and therefore suggest to add it to opm-common

totto82 avatar Aug 28 '24 12:08 totto82

The idea is to apply the ML-Keras inside OPM for different tasks [...] Since the ML-Keras model framework is general, we hope it would be useful for the OPM community and therefore suggest to add it to opm-common

Okay, utility/convenience is clearly one reason for adding it here. Would it be impossible to make [your/certain use cases] work if it were located elsewhere? Do you, for instance, need access to the internals/private data members or member functions of Well or Connection objects or similar in your use cases?

bska avatar Aug 28 '24 12:08 bska

jenkins build this please

totto82 avatar Aug 28 '24 13:08 totto82

The idea is to apply the ML-Keras inside OPM for different tasks [...] Since the ML-Keras model framework is general, we hope it would be useful for the OPM community and therefore suggest to add it to opm-common

Okay, utility/convenience is clearly one reason for adding it here. Would it be impossible to make [your/certain use cases] work if it were located elsewhere? Do you, for instance, need access to the internals/private data members or member functions of Well or Connection objects or similar in your use cases?

Exact! For instance, we need access to the automatic differentiation tools within OPM.

bikagit avatar Sep 01 '24 05:09 bikagit

jenkins build this please

totto82 avatar Sep 06 '24 13:09 totto82

Thanks all for the valuables comments and suggestions. We have started adding most of the modifications.

bikagit avatar Sep 27 '24 14:09 bikagit

jenkins build this please

daavid00 avatar Oct 11 '24 15:10 daavid00

jenkins build this please

daavid00 avatar Oct 11 '24 15:10 daavid00

Note that in addition to re-commenting on several of the unchanged problems, I un-resolved several more since the existing comment was still valid. Please make code changes first, in a separate commit so I can easily see what changes you made, then after that add a separate commit to do the auto-reformatting.

atgeirr avatar Jan 02 '25 13:01 atgeirr

Note that in addition to re-commenting on several of the unchanged problems, I un-resolved several more since the existing comment was still valid. Please make code changes first, in a separate commit so I can easily see what changes you made, then after that add a separate commit to do the auto-reformatting.

Thanks for spotting the missing points. The changes were done in November. However, unfortunately, during re-basing we removed some commits inadvertently. The requested changes will all be added back.

bikagit avatar Jan 03 '25 09:01 bikagit

jenkins build this please

totto82 avatar Jan 16 '25 12:01 totto82

jenkins build this please

totto82 avatar Jan 20 '25 13:01 totto82

jenkins build this please

daavid00 avatar Jan 20 '25 14:01 daavid00

jenkins build this please

daavid00 avatar Jan 21 '25 06:01 daavid00

jenkins build this please

atgeirr avatar Jan 24 '25 15:01 atgeirr

Finally, all is green and ok! Merging.

atgeirr avatar Jan 27 '25 11:01 atgeirr