diff --git a/opm/ml/LICENSE.MIT b/opm/ml/LICENSE.MIT new file mode 100644 index 00000000000..6908c245ebf --- /dev/null +++ b/opm/ml/LICENSE.MIT @@ -0,0 +1,19 @@ +Copyright (c) 2016 Robert W. Rose, 2018 Paul Maevskikh, 2024 NORCE + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/opm/ml/keras_model.cpp b/opm/ml/keras_model.cpp index 46a191c9e22..30530ba73b3 100644 --- a/opm/ml/keras_model.cpp +++ b/opm/ml/keras_model.cpp @@ -3,12 +3,11 @@ * Copyright (c) 2016 Robert W. Rose * Copyright (c) 2018 Paul Maevskikh * - * MIT License, see LICENSE.OLD file. + * MIT License, see LICENSE.MIT file. */ /* - * Copyright (c) 2024 Birane Kane - * Copyright (c) 2024 Tor Harald Sandve + Copyright (c) 2024 NORCE This file is part of the Open Porous Media project (OPM). OPM is free software: you can redistribute it and/or modify @@ -37,8 +36,6 @@ namespace Opm { -#pragma once - bool ReadUnsignedInt(std::ifstream* file, unsigned int* i) { KASSERT(file, "Invalid file stream"); diff --git a/opm/ml/keras_model.hpp b/opm/ml/keras_model.hpp index f84ea106bbf..40a77ce81f3 100644 --- a/opm/ml/keras_model.hpp +++ b/opm/ml/keras_model.hpp @@ -3,12 +3,11 @@ * Copyright (c) 2016 Robert W. Rose * Copyright (c) 2018 Paul Maevskikh * - * MIT License, see LICENSE.OLD file. + * MIT License, see LICENSE.MIT file. */ /* - * Copyright (c) 2024 Birane Kane - * Copyright (c) 2024 Tor Harald Sandve + Copyright (c) 2024 NORCE This file is part of the Open Porous Media project (OPM). OPM is free software: you can redistribute it and/or modify diff --git a/opm/ml/keras_model_test.cpp b/opm/ml/keras_model_test.cpp index 354e744e950..cb597208fbb 100644 --- a/opm/ml/keras_model_test.cpp +++ b/opm/ml/keras_model_test.cpp @@ -3,12 +3,11 @@ * Copyright (c) 2016 Robert W. Rose * Copyright (c) 2018 Paul Maevskikh * - * MIT License, see LICENSE.OLD file. + * MIT License, see LICENSE.MIT file. */ /* - * Copyright (c) 2024 Birane Kane - * Copyright (c) 2024 Tor Harald Sandve + Copyright (c) 2024 NORCE This file is part of the Open Porous Media project (OPM). OPM is free software: you can redistribute it and/or modify diff --git a/opm/ml/ml_tools/generateunittests.py b/opm/ml/ml_tools/generateunittests.py index fa36a0681b5..c736c5cf43f 100644 --- a/opm/ml/ml_tools/generateunittests.py +++ b/opm/ml/ml_tools/generateunittests.py @@ -1,6 +1,4 @@ -# Copyright (c) 2024 Birane Kane -# Copyright (c) 2024 Tor Harald Sandve - +# Copyright (c) 2024 NORCE # This file is part of the Open Porous Media project (OPM). # OPM is free software: you can redistribute it and/or modify diff --git a/opm/ml/ml_tools/include/test_dense_10x1.h b/opm/ml/ml_tools/include/test_dense_10x1.h index 7306e3f47c8..85f93a05c71 100644 --- a/opm/ml/ml_tools/include/test_dense_10x1.h +++ b/opm/ml/ml_tools/include/test_dense_10x1.h @@ -25,6 +25,7 @@ You should have received a copy of the GNU General Public License along with OPM. If not, see . */ + #include #include namespace fs = std::filesystem; @@ -39,11 +40,11 @@ bool test_dense_10x1(Evaluation* load_time, Evaluation* apply_time) KASSERT(apply_time, "Invalid Evaluation"); Opm::Tensor in{10}; - in.data_ = {0.07588807,0.46424174,0.2545689,0.24965246,0.48471555,0.9185193, -0.33841145,0.30067867,0.98624486,0.85875916}; + in.data_ = {0.028337156,0.47675753,0.2153181,0.7789775,0.14985214,0.79748774, +0.2248302,0.2768584,0.026402472,0.96524626}; Opm::Tensor out{1}; - out.data_ = {-0.6094914}; + out.data_ = {-0.045620237}; KerasTimer load_timer; load_timer.Start(); diff --git a/opm/ml/ml_tools/include/test_dense_10x10.h b/opm/ml/ml_tools/include/test_dense_10x10.h index 1f14f6f5739..2955b7e061a 100644 --- a/opm/ml/ml_tools/include/test_dense_10x10.h +++ b/opm/ml/ml_tools/include/test_dense_10x10.h @@ -25,6 +25,7 @@ You should have received a copy of the GNU General Public License along with OPM. If not, see . */ + #include #include namespace fs = std::filesystem; @@ -39,11 +40,11 @@ bool test_dense_10x10(Evaluation* load_time, Evaluation* apply_time) KASSERT(apply_time, "Invalid Evaluation"); Opm::Tensor in{10}; - in.data_ = {0.74464816,0.063315846,0.2233216,0.3184675,0.017677268,0.24977225, -0.5242765,0.27742663,0.009411842,0.27946305}; + in.data_ = {0.57140607,0.8967398,0.9760273,0.9114512,0.008267918,0.7468546, +0.3212238,0.46343815,0.8251662,0.0512341}; Opm::Tensor out{1}; - out.data_ = {0.06583358}; + out.data_ = {-0.58098537}; KerasTimer load_timer; load_timer.Start(); diff --git a/opm/ml/ml_tools/include/test_dense_10x10x10.h b/opm/ml/ml_tools/include/test_dense_10x10x10.h index d373bffc066..8ede0b814f8 100644 --- a/opm/ml/ml_tools/include/test_dense_10x10x10.h +++ b/opm/ml/ml_tools/include/test_dense_10x10x10.h @@ -25,6 +25,7 @@ You should have received a copy of the GNU General Public License along with OPM. If not, see . */ + #include #include namespace fs = std::filesystem; @@ -39,12 +40,12 @@ bool test_dense_10x10x10(Evaluation* load_time, Evaluation* apply_time) KASSERT(apply_time, "Invalid Evaluation"); Opm::Tensor in{10}; - in.data_ = {0.84246427,0.15756324,0.8924635,0.5069177,0.8633376,0.31142905, -0.7651278,0.5454816,0.22917923,0.54828155}; + in.data_ = {0.22960497,0.92062306,0.37085533,0.79550546,0.6544509,0.78485596, +0.64225894,0.25924394,0.05619732,0.8523417}; Opm::Tensor out{10}; - out.data_ = {0.767188,0.23175952,0.036515277,-0.2622609,-0.25455678, -0.157909,-0.6259325,-0.6256348,0.4324326,-0.4141315}; + out.data_ = {0.4929909,0.61837775,-0.56747174,-0.2169362,0.5226636,0.27694574, +-0.4490728,-0.38884047,0.31565535,-0.29196134}; KerasTimer load_timer; load_timer.Start(); diff --git a/opm/ml/ml_tools/include/test_dense_1x1.h b/opm/ml/ml_tools/include/test_dense_1x1.h index 5410cee5d08..545568c09e0 100644 --- a/opm/ml/ml_tools/include/test_dense_1x1.h +++ b/opm/ml/ml_tools/include/test_dense_1x1.h @@ -25,6 +25,7 @@ You should have received a copy of the GNU General Public License along with OPM. If not, see . */ + #include #include namespace fs = std::filesystem; diff --git a/opm/ml/ml_tools/include/test_dense_2x2.h b/opm/ml/ml_tools/include/test_dense_2x2.h index 1bbfe040217..f8ab1fc72db 100644 --- a/opm/ml/ml_tools/include/test_dense_2x2.h +++ b/opm/ml/ml_tools/include/test_dense_2x2.h @@ -25,6 +25,7 @@ You should have received a copy of the GNU General Public License along with OPM. If not, see . */ + #include #include namespace fs = std::filesystem; @@ -39,10 +40,10 @@ bool test_dense_2x2(Evaluation* load_time, Evaluation* apply_time) KASSERT(apply_time, "Invalid Evaluation"); Opm::Tensor in{2}; - in.data_ = {0.6440019,0.62654394}; + in.data_ = {0.43962377,0.01062112}; Opm::Tensor out{1}; - out.data_ = {0.7173992}; + out.data_ = {0.3840781}; KerasTimer load_timer; load_timer.Start(); diff --git a/opm/ml/ml_tools/include/test_dense_relu_10.h b/opm/ml/ml_tools/include/test_dense_relu_10.h index 2031e90b6f3..8fe0e05768a 100644 --- a/opm/ml/ml_tools/include/test_dense_relu_10.h +++ b/opm/ml/ml_tools/include/test_dense_relu_10.h @@ -25,6 +25,7 @@ You should have received a copy of the GNU General Public License along with OPM. If not, see . */ + #include #include namespace fs = std::filesystem; @@ -39,12 +40,12 @@ bool test_dense_relu_10(Evaluation* load_time, Evaluation* apply_time) KASSERT(apply_time, "Invalid Evaluation"); Opm::Tensor in{10}; - in.data_ = {0.58381814,0.90178627,0.13896127,0.18618706,0.94524324,0.11974335, -0.88227147,0.09502208,0.71341133,0.53053087}; + in.data_ = {0.19831748,0.42010197,0.8982862,0.944561,0.8837304, +0.6614817,0.0130608175,0.110780664,0.78615165,0.9631918}; Opm::Tensor out{10}; - out.data_ = {0.,0.,0.,0.,0.,0.20002396, -0.19065511,0.,0.,0.1995258}; + out.data_ = {0.026521523,0.052303486,0.,0.059044015,0.15992397,0.22082125, +0.02430303,0.041414373,0.,0.}; KerasTimer load_timer; load_timer.Start(); diff --git a/opm/ml/ml_tools/include/test_dense_tanh_10.h b/opm/ml/ml_tools/include/test_dense_tanh_10.h index 9785b41416d..c123b2d3944 100644 --- a/opm/ml/ml_tools/include/test_dense_tanh_10.h +++ b/opm/ml/ml_tools/include/test_dense_tanh_10.h @@ -25,6 +25,7 @@ You should have received a copy of the GNU General Public License along with OPM. If not, see . */ + #include #include namespace fs = std::filesystem; @@ -39,12 +40,12 @@ bool test_dense_tanh_10(Evaluation* load_time, Evaluation* apply_time) KASSERT(apply_time, "Invalid Evaluation"); Opm::Tensor in{10}; - in.data_ = {0.5133757,0.8992964,0.018602798,0.8300745,0.43004134,0.16437091, -0.13667183,0.7081913,0.39895463,0.53926337}; + in.data_ = {0.94178486,0.97045666,0.26675382,0.15001157,0.058416706,0.4708675, +0.32430366,0.663224,0.83338004,0.07695259}; Opm::Tensor out{10}; - out.data_ = {-0.16390416,-0.11630989,0.37623432,-0.65770155,0.1101914, --0.097250186,0.5037399,-0.2223558,0.3810121,0.6196858}; + out.data_ = {-0.3836348,-0.3243347,-0.27209598,0.7553107,0.39941213,0.33857337, +0.3022548,0.5558565,0.25710058,0.06801057}; KerasTimer load_timer; load_timer.Start(); diff --git a/opm/ml/ml_tools/include/test_relu_10.h b/opm/ml/ml_tools/include/test_relu_10.h index 86d8e3c9611..9fdc96b1642 100644 --- a/opm/ml/ml_tools/include/test_relu_10.h +++ b/opm/ml/ml_tools/include/test_relu_10.h @@ -25,6 +25,7 @@ You should have received a copy of the GNU General Public License along with OPM. If not, see . */ + #include #include namespace fs = std::filesystem; @@ -39,12 +40,12 @@ bool test_relu_10(Evaluation* load_time, Evaluation* apply_time) KASSERT(apply_time, "Invalid Evaluation"); Opm::Tensor in{10}; - in.data_ = {0.120741345,0.59726936,0.9251051,0.87210053,0.6669108,0.13732599, -0.3093547,0.77527475,0.3986614,0.943842}; + in.data_ = {0.5720142,0.7958312,0.49442244,0.5607951,0.64218307,0.7643652, +0.5172547,0.5801977,0.4463315,0.7367068}; Opm::Tensor out{10}; - out.data_ = {0.,0.,0.48979148,0.,1.1085179,0., -0.,0.33353794,0.7359366,0.8868316}; + out.data_ = {0.,1.231329,0.6788606,0.47707865,0.,0., +0.03563368,0.,0.185271,1.0702842}; KerasTimer load_timer; load_timer.Start(); diff --git a/opm/ml/ml_tools/include/test_scalingdense_1x1.h b/opm/ml/ml_tools/include/test_scalingdense_1x1.h index 3e16e372023..779008411ee 100644 --- a/opm/ml/ml_tools/include/test_scalingdense_1x1.h +++ b/opm/ml/ml_tools/include/test_scalingdense_1x1.h @@ -25,6 +25,7 @@ You should have received a copy of the GNU General Public License along with OPM. If not, see . */ + #include #include namespace fs = std::filesystem; @@ -39,12 +40,12 @@ bool test_scalingdense_1x1(Evaluation* load_time, Evaluation* apply_time) KASSERT(apply_time, "Invalid Evaluation"); Opm::Tensor in{10}; - in.data_ = {0.22338921,0.8132339,0.43024784,0.26458433,0.92503846,0.6615654, -0.88089544,0.34508273,0.6916904,0.57852364}; + in.data_ = {0.57866585,0.7809936,0.5699105,0.6669938,0.49444735,0.35300153, +0.11979457,0.788769,0.56031364,0.7564715}; Opm::Tensor out{10}; - out.data_ = {670.77625,672.4989,709.0858,640.06885,827.44714,736.1234,617.30554, -638.03955,629.93115,653.84595}; + out.data_ = {188.2261,189.02136,211.52573,165.40366,164.43533,201.74683,160.93051, +188.01346,211.02103,178.08841}; KerasTimer load_timer; load_timer.Start(); diff --git a/opm/ml/ml_tools/kerasify.py b/opm/ml/ml_tools/kerasify.py index a91dc615941..8dde9e054bb 100644 --- a/opm/ml/ml_tools/kerasify.py +++ b/opm/ml/ml_tools/kerasify.py @@ -1,6 +1,12 @@ -# Copyright (c) 2024 Birane Kane -# Copyright (c) 2024 Tor Harald Sandve +# /* +# * Copyright (c) 2016 Robert W. Rose +# * Copyright (c) 2018 Paul Maevskikh +# * +# * MIT License, see LICENSE.MIT file. +# */ + +# Copyright (c) 2024 NORCE # This file is part of the Open Porous Media project (OPM). # OPM is free software: you can redistribute it and/or modify diff --git a/opm/ml/ml_tools/models/test_dense_10x1.model b/opm/ml/ml_tools/models/test_dense_10x1.model index 4f3e572a68d..be72f5d0e2f 100644 Binary files a/opm/ml/ml_tools/models/test_dense_10x1.model and b/opm/ml/ml_tools/models/test_dense_10x1.model differ diff --git a/opm/ml/ml_tools/models/test_dense_10x10.model b/opm/ml/ml_tools/models/test_dense_10x10.model index 0317b1d6e80..31154b7c21e 100644 Binary files a/opm/ml/ml_tools/models/test_dense_10x10.model and b/opm/ml/ml_tools/models/test_dense_10x10.model differ diff --git a/opm/ml/ml_tools/models/test_dense_10x10x10.model b/opm/ml/ml_tools/models/test_dense_10x10x10.model index 504d3caa17a..674cd7d1aed 100644 Binary files a/opm/ml/ml_tools/models/test_dense_10x10x10.model and b/opm/ml/ml_tools/models/test_dense_10x10x10.model differ diff --git a/opm/ml/ml_tools/models/test_dense_1x1.model b/opm/ml/ml_tools/models/test_dense_1x1.model index c512d9dd927..88f8347f94a 100644 Binary files a/opm/ml/ml_tools/models/test_dense_1x1.model and b/opm/ml/ml_tools/models/test_dense_1x1.model differ diff --git a/opm/ml/ml_tools/models/test_dense_2x2.model b/opm/ml/ml_tools/models/test_dense_2x2.model index 7fe8b18bb83..8bafb7372d9 100644 Binary files a/opm/ml/ml_tools/models/test_dense_2x2.model and b/opm/ml/ml_tools/models/test_dense_2x2.model differ diff --git a/opm/ml/ml_tools/models/test_dense_relu_10.model b/opm/ml/ml_tools/models/test_dense_relu_10.model index 41aeed0b4f3..fd0a24ad2c4 100644 Binary files a/opm/ml/ml_tools/models/test_dense_relu_10.model and b/opm/ml/ml_tools/models/test_dense_relu_10.model differ diff --git a/opm/ml/ml_tools/models/test_dense_tanh_10.model b/opm/ml/ml_tools/models/test_dense_tanh_10.model index efadda6e44d..740a7e458a6 100644 Binary files a/opm/ml/ml_tools/models/test_dense_tanh_10.model and b/opm/ml/ml_tools/models/test_dense_tanh_10.model differ diff --git a/opm/ml/ml_tools/models/test_relu_10.model b/opm/ml/ml_tools/models/test_relu_10.model index d9597021154..1d15c26177f 100644 Binary files a/opm/ml/ml_tools/models/test_relu_10.model and b/opm/ml/ml_tools/models/test_relu_10.model differ diff --git a/opm/ml/ml_tools/models/test_scalingdense_1x1.model b/opm/ml/ml_tools/models/test_scalingdense_1x1.model index 7baf2c16f3f..d5af87bcc91 100644 Binary files a/opm/ml/ml_tools/models/test_scalingdense_1x1.model and b/opm/ml/ml_tools/models/test_scalingdense_1x1.model differ diff --git a/opm/ml/ml_tools/scaler_layers.py b/opm/ml/ml_tools/scaler_layers.py index ca77c60f7e3..80c26483aa3 100644 --- a/opm/ml/ml_tools/scaler_layers.py +++ b/opm/ml/ml_tools/scaler_layers.py @@ -1,5 +1,4 @@ -# Copyright (c) 2024 Birane Kane -# Copyright (c) 2024 Tor Harald Sandve +# Copyright (c) 2024 NORCE # Copyright (c) 2024 Peter Moritz von Schultzendorff # This file is part of the Open Porous Media project (OPM). diff --git a/opm/ml/ml_tools/scalertest.py b/opm/ml/ml_tools/scalertest.py index a662bc1da5a..ba4c8c7802a 100644 --- a/opm/ml/ml_tools/scalertest.py +++ b/opm/ml/ml_tools/scalertest.py @@ -1,5 +1,4 @@ -# Copyright (c) 2024 Birane Kane -# Copyright (c) 2024 Tor Harald Sandve +# Copyright (c) 2024 NORCE # Copyright (c) 2024 Peter Moritz von Schultzendorff # This file is part of the Open Porous Media project (OPM).