Skip to content

Commit

Permalink
adding MITLicensing
Browse files Browse the repository at this point in the history
  • Loading branch information
fractalmanifold committed Aug 22, 2024
1 parent 7ffe97c commit 230460c
Show file tree
Hide file tree
Showing 26 changed files with 73 additions and 48 deletions.
19 changes: 19 additions & 0 deletions opm/ml/LICENSE.MIT
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 2 additions & 5 deletions opm/ml/keras_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -37,8 +36,6 @@

namespace Opm {

#pragma once


bool ReadUnsignedInt(std::ifstream* file, unsigned int* i) {
KASSERT(file, "Invalid file stream");
Expand Down
5 changes: 2 additions & 3 deletions opm/ml/keras_model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions opm/ml/keras_model_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions opm/ml/ml_tools/generateunittests.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 4 additions & 3 deletions opm/ml/ml_tools/include/test_dense_10x1.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/

#include <filesystem>
#include <iostream>
namespace fs = std::filesystem;
Expand All @@ -39,11 +40,11 @@ bool test_dense_10x1(Evaluation* load_time, Evaluation* apply_time)
KASSERT(apply_time, "Invalid Evaluation");

Opm::Tensor<Evaluation> 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<Evaluation> out{1};
out.data_ = {-0.6094914};
out.data_ = {-0.045620237};

KerasTimer load_timer;
load_timer.Start();
Expand Down
7 changes: 4 additions & 3 deletions opm/ml/ml_tools/include/test_dense_10x10.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/

#include <filesystem>
#include <iostream>
namespace fs = std::filesystem;
Expand All @@ -39,11 +40,11 @@ bool test_dense_10x10(Evaluation* load_time, Evaluation* apply_time)
KASSERT(apply_time, "Invalid Evaluation");

Opm::Tensor<Evaluation> 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<Evaluation> out{1};
out.data_ = {0.06583358};
out.data_ = {-0.58098537};

KerasTimer load_timer;
load_timer.Start();
Expand Down
9 changes: 5 additions & 4 deletions opm/ml/ml_tools/include/test_dense_10x10x10.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/

#include <filesystem>
#include <iostream>
namespace fs = std::filesystem;
Expand All @@ -39,12 +40,12 @@ bool test_dense_10x10x10(Evaluation* load_time, Evaluation* apply_time)
KASSERT(apply_time, "Invalid Evaluation");

Opm::Tensor<Evaluation> 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<Evaluation> 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();
Expand Down
1 change: 1 addition & 0 deletions opm/ml/ml_tools/include/test_dense_1x1.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/

#include <filesystem>
#include <iostream>
namespace fs = std::filesystem;
Expand Down
5 changes: 3 additions & 2 deletions opm/ml/ml_tools/include/test_dense_2x2.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/

#include <filesystem>
#include <iostream>
namespace fs = std::filesystem;
Expand All @@ -39,10 +40,10 @@ bool test_dense_2x2(Evaluation* load_time, Evaluation* apply_time)
KASSERT(apply_time, "Invalid Evaluation");

Opm::Tensor<Evaluation> in{2};
in.data_ = {0.6440019,0.62654394};
in.data_ = {0.43962377,0.01062112};

Opm::Tensor<Evaluation> out{1};
out.data_ = {0.7173992};
out.data_ = {0.3840781};

KerasTimer load_timer;
load_timer.Start();
Expand Down
9 changes: 5 additions & 4 deletions opm/ml/ml_tools/include/test_dense_relu_10.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/

#include <filesystem>
#include <iostream>
namespace fs = std::filesystem;
Expand All @@ -39,12 +40,12 @@ bool test_dense_relu_10(Evaluation* load_time, Evaluation* apply_time)
KASSERT(apply_time, "Invalid Evaluation");

Opm::Tensor<Evaluation> 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<Evaluation> 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();
Expand Down
9 changes: 5 additions & 4 deletions opm/ml/ml_tools/include/test_dense_tanh_10.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/

#include <filesystem>
#include <iostream>
namespace fs = std::filesystem;
Expand All @@ -39,12 +40,12 @@ bool test_dense_tanh_10(Evaluation* load_time, Evaluation* apply_time)
KASSERT(apply_time, "Invalid Evaluation");

Opm::Tensor<Evaluation> 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<Evaluation> 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();
Expand Down
9 changes: 5 additions & 4 deletions opm/ml/ml_tools/include/test_relu_10.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/

#include <filesystem>
#include <iostream>
namespace fs = std::filesystem;
Expand All @@ -39,12 +40,12 @@ bool test_relu_10(Evaluation* load_time, Evaluation* apply_time)
KASSERT(apply_time, "Invalid Evaluation");

Opm::Tensor<Evaluation> 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<Evaluation> 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();
Expand Down
9 changes: 5 additions & 4 deletions opm/ml/ml_tools/include/test_scalingdense_1x1.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/

#include <filesystem>
#include <iostream>
namespace fs = std::filesystem;
Expand All @@ -39,12 +40,12 @@ bool test_scalingdense_1x1(Evaluation* load_time, Evaluation* apply_time)
KASSERT(apply_time, "Invalid Evaluation");

Opm::Tensor<Evaluation> 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<Evaluation> 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();
Expand Down
10 changes: 8 additions & 2 deletions opm/ml/ml_tools/kerasify.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Binary file modified opm/ml/ml_tools/models/test_dense_10x1.model
Binary file not shown.
Binary file modified opm/ml/ml_tools/models/test_dense_10x10.model
Binary file not shown.
Binary file modified opm/ml/ml_tools/models/test_dense_10x10x10.model
Binary file not shown.
Binary file modified opm/ml/ml_tools/models/test_dense_1x1.model
Binary file not shown.
Binary file modified opm/ml/ml_tools/models/test_dense_2x2.model
Binary file not shown.
Binary file modified opm/ml/ml_tools/models/test_dense_relu_10.model
Binary file not shown.
Binary file modified opm/ml/ml_tools/models/test_dense_tanh_10.model
Binary file not shown.
Binary file modified opm/ml/ml_tools/models/test_relu_10.model
Binary file not shown.
Binary file modified opm/ml/ml_tools/models/test_scalingdense_1x1.model
Binary file not shown.
3 changes: 1 addition & 2 deletions opm/ml/ml_tools/scaler_layers.py
Original file line number Diff line number Diff line change
@@ -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).
Expand Down
3 changes: 1 addition & 2 deletions opm/ml/ml_tools/scalertest.py
Original file line number Diff line number Diff line change
@@ -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).
Expand Down

0 comments on commit 230460c

Please sign in to comment.