gfdl 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
gfdl-0.1.0/COPYING ADDED
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2025-2026 Los Alamos National Laboratory.
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ * Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
gfdl-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,33 @@
1
+ Metadata-Version: 2.4
2
+ Name: gfdl
3
+ Version: 0.1.0
4
+ Summary: Gradient Free Deep Learning (GFDL) networks including single and multi layer random vector functional link (RVFL) networks and extreme learning machines (ELMs)
5
+ Project-URL: source, https://github.com/lanl/GFDL
6
+ Project-URL: download, https://github.com/lanl/GFDL/releases
7
+ Project-URL: tracker, https://github.com/lanl/GFDL/issues
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Topic :: Software Development :: Libraries
17
+ Classifier: Topic :: Scientific/Engineering
18
+ Classifier: Operating System :: Microsoft :: Windows
19
+ Classifier: Operating System :: POSIX :: Linux
20
+ Classifier: Operating System :: POSIX
21
+ Classifier: Operating System :: Unix
22
+ Classifier: Operating System :: MacOS
23
+ Requires-Python: >=3.12
24
+ License-File: COPYING
25
+ Requires-Dist: numpy<2.7,>=2.0.0
26
+ Requires-Dist: scikit-learn<1.11,>=1.5.0
27
+ Requires-Dist: scipy<1.20,>=1.13.0
28
+ Requires-Dist: packaging<27.0,>=24.0
29
+ Provides-Extra: test
30
+ Requires-Dist: ucimlrepo; extra == "test"
31
+ Requires-Dist: pytest; extra == "test"
32
+ Requires-Dist: pytest-cov; extra == "test"
33
+ Dynamic: license-file
gfdl-0.1.0/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # Gradient Free Deep Learning (GFDL) -- LANL O5013
2
+
3
+ ## Introduction
4
+ This is a Python library that provides a variety of `scikit-learn` conformant
5
+ machine learning estimators that do not use backpropagation. The most
6
+ prominent estimator types we support provide access to single and multi layer
7
+ random vector functional link (RVFL) networks and extreme learning machines
8
+ (ELMs). There is a considerable background literate on these two types
9
+ of gradient free networks, and one obvious advantage of being gradient free
10
+ is that expensive hardware devices are not required to train the models
11
+ efficiently.
12
+
13
+ ## Contribution Guidelines
14
+
15
+ 1. We use an open source license that is compatible with the rest of the
16
+ scientific Python ecosystem, so please do not provide contributions that
17
+ have a potential to be copyleft. For example, do not copy or even read code
18
+ from libraries that have a GPL or other copyleft-style license, as we cannot
19
+ accept it while retaining our more liberal software license.
20
+ 2. At the moment it is not acceptable to use machine learning/AI/LLMs as
21
+ part of the code contribution/review process. The reason is related to provenance
22
+ and licensing---we cannot know for sure if the material being contributed
23
+ originated or partially originated from code that had a copyleft license.
24
+ 3. Please make an effort to format your PR titles and commit messages
25
+ according to the [guidelines used provided by NumPy](https://numpy.org/devdocs/dev/development_workflow.html#writing-the-commit-message). This helps keep our commit
26
+ history readable and easier to debug.
27
+ 4. Please try to avoid merging your own code---we aim to provide timely
28
+ code reviews and have developers merge the code of others when they are
29
+ satisfied.
30
+ 5. Please add regression tests for bug fixes and new features, and avoid
31
+ making unrelated changes (i.e., formatting changes to other parts of the
32
+ code alongside a bug fix or improvement).
@@ -0,0 +1,65 @@
1
+ [build-system]
2
+ requires = ["setuptools>=69,<80.11.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "gfdl"
7
+ version = "0.1.0"
8
+ description = "Gradient Free Deep Learning (GFDL) networks including single and multi layer random vector functional link (RVFL) networks and extreme learning machines (ELMs)"
9
+ requires-python = ">=3.12"
10
+ classifiers = [
11
+ "Development Status :: 4 - Beta",
12
+ "Intended Audience :: Science/Research",
13
+ "Intended Audience :: Developers",
14
+ "Programming Language :: Python",
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3.12",
17
+ "Programming Language :: Python :: 3.13",
18
+ "Programming Language :: Python :: 3.14",
19
+ "Topic :: Software Development :: Libraries",
20
+ "Topic :: Scientific/Engineering",
21
+ "Operating System :: Microsoft :: Windows",
22
+ "Operating System :: POSIX :: Linux",
23
+ "Operating System :: POSIX",
24
+ "Operating System :: Unix",
25
+ "Operating System :: MacOS",
26
+ ]
27
+ dependencies = ["numpy>=2.0.0,<2.7",
28
+ "scikit-learn>=1.5.0,<1.11",
29
+ "scipy>=1.13.0,<1.20",
30
+ "packaging>=24.0,<27.0"]
31
+
32
+ [project.urls]
33
+ source = "https://github.com/lanl/GFDL"
34
+ download = "https://github.com/lanl/GFDL/releases"
35
+ tracker = "https://github.com/lanl/GFDL/issues"
36
+
37
+ [tool.setuptools.packages.find]
38
+ where = ["src"]
39
+
40
+ [tool.setuptools.package-data]
41
+ gfdl = ["testdata/**/*"]
42
+
43
+
44
+ [project.optional-dependencies]
45
+ test = [
46
+ "ucimlrepo",
47
+ "pytest",
48
+ "pytest-cov",
49
+ ]
50
+
51
+ [tool.numpydoc_validation]
52
+ checks = [
53
+ "all", # report on all checks, except the below
54
+ "EX01", # we don't require examples sections yet
55
+ "SA01", # we don't require "See Also" sections
56
+ "ES01", # we don't require extended summaries
57
+ ]
58
+
59
+ exclude = [
60
+ '\.__init__$',
61
+ '\._check_voting$',
62
+ '\._forward$',
63
+ 'EnsembleGFDL(\.|$)', # ignore base class
64
+ 'GFDL(\.|$)', # ignore base class
65
+ ]
gfdl-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,36 @@
1
+ import platform
2
+
3
+ import numpy as np
4
+ import packaging
5
+ import scipy
6
+ import sklearn
7
+ from packaging.version import Version
8
+
9
+ from .model import GFDL
10
+
11
+ __all__ = ["GFDL"]
12
+
13
+ packaging_version = Version(packaging.__version__)
14
+ min_packaging_version = "24.0"
15
+ if packaging_version < Version(min_packaging_version):
16
+ raise ImportError(f"{packaging_version=}, but {min_packaging_version=}")
17
+
18
+ python_version = Version(platform.python_version())
19
+ min_python_version = "3.12"
20
+ if python_version < Version(min_python_version):
21
+ raise ImportError(f"{python_version=}, but {min_python_version=}")
22
+
23
+ numpy_version = Version(np.__version__)
24
+ min_numpy_version = "2.0.0"
25
+ if numpy_version < Version(min_numpy_version):
26
+ raise ImportError(f"{numpy_version=}, but {min_numpy_version=}")
27
+
28
+ sklearn_version = Version(sklearn.__version__)
29
+ min_sklearn_version = "1.5.0"
30
+ if sklearn_version < Version(min_sklearn_version):
31
+ raise ImportError(f"{sklearn_version=}, but {min_sklearn_version=}")
32
+
33
+ scipy_version = Version(scipy.__version__)
34
+ min_scipy_version = "1.13.0"
35
+ if scipy_version < Version(min_scipy_version):
36
+ raise ImportError(f"{scipy_version=}, but {min_scipy_version=}")
@@ -0,0 +1,194 @@
1
+ """
2
+ Activation functions for Gradient Free Deep Learning estimators.
3
+ """
4
+
5
+ import numpy as np
6
+ import scipy
7
+
8
+
9
+ def relu(z):
10
+ """
11
+ The rectified linear unit activation function.
12
+
13
+ Parameters
14
+ ----------
15
+ z : array_like
16
+ Input array.
17
+
18
+ Returns
19
+ -------
20
+ numpy.ndarray
21
+ The output array with only positive values.
22
+ """
23
+ return np.maximum(0, z)
24
+
25
+
26
+ def tanh(z):
27
+ """
28
+ The hyperbolic tangent activation function.
29
+
30
+ Parameters
31
+ ----------
32
+ z : array_like
33
+ Input array.
34
+
35
+ Returns
36
+ -------
37
+ numpy.ndarray
38
+ The output array with hyperbolic tangent values.
39
+
40
+ See Also
41
+ --------
42
+ numpy.tanh : The hyperbolic tangent function.
43
+ """
44
+ return np.tanh(z)
45
+
46
+
47
+ def sigmoid(z):
48
+ """
49
+ The logistic sigmoid activation function.
50
+
51
+ Parameters
52
+ ----------
53
+ z : array_like
54
+ Input array.
55
+
56
+ Returns
57
+ -------
58
+ numpy.ndarray
59
+ The output array with the function values.
60
+
61
+ See Also
62
+ --------
63
+ scipy.special.expit : The logistic sigmoid function.
64
+ """
65
+ return scipy.special.expit(z)
66
+
67
+
68
+ def identity(z):
69
+ """
70
+ The identity activation function.
71
+
72
+ Parameters
73
+ ----------
74
+ z : array_like
75
+ Input array.
76
+
77
+ Returns
78
+ -------
79
+ numpy.ndarray
80
+ The input array is returned unchanged.
81
+ """
82
+ return z
83
+
84
+
85
+ def softmax(z):
86
+ """
87
+ The softmax activation function.
88
+
89
+ Parameters
90
+ ----------
91
+ z : array_like
92
+ Input array.
93
+
94
+ Returns
95
+ -------
96
+ numpy.ndarray
97
+ The output array with the function values.
98
+
99
+ See Also
100
+ --------
101
+ scipy.special.softmax : The softmax function.
102
+ """
103
+ return scipy.special.softmax(z, axis=-1)
104
+
105
+
106
+ def softmin(z):
107
+ """
108
+ The softmin activation function.
109
+
110
+ It is the softmax function applied to negative of the input values.
111
+
112
+ Parameters
113
+ ----------
114
+ z : array_like
115
+ Input array.
116
+
117
+ Returns
118
+ -------
119
+ numpy.ndarray
120
+ The output array with the function values.
121
+
122
+ See Also
123
+ --------
124
+ scipy.special.softmax : The softmax function.
125
+ """
126
+ return softmax(-z)
127
+
128
+
129
+ def log_sigmoid(z):
130
+ """
131
+ The logarithm of logistic sigmoid activation function.
132
+
133
+ Parameters
134
+ ----------
135
+ z : array_like
136
+ Input array.
137
+
138
+ Returns
139
+ -------
140
+ numpy.ndarray
141
+ The output array with the function values.
142
+
143
+ See Also
144
+ --------
145
+ scipy.special.log_expit : The logistic sigmoid function.
146
+ """
147
+ return scipy.special.log_expit(z)
148
+
149
+
150
+ def log_softmax(z):
151
+ """
152
+ The log softmax activation function.
153
+
154
+ Parameters
155
+ ----------
156
+ z : array_like
157
+ Input array.
158
+
159
+ Returns
160
+ -------
161
+ numpy.ndarray
162
+ The output array with the function values.
163
+
164
+ See Also
165
+ --------
166
+ scipy.special.log_softmax : The logarithm of softmax function.
167
+ """
168
+ return scipy.special.log_softmax(z, axis=-1)
169
+
170
+
171
+ ACTIVATIONS = {
172
+ "relu": relu,
173
+ "tanh": tanh,
174
+ "sigmoid": sigmoid,
175
+ "identity": identity,
176
+ "linear": identity,
177
+ "softmax": softmax,
178
+ "softmin": softmin,
179
+ "log_sigmoid": log_sigmoid,
180
+ "log_softmax": log_softmax,
181
+ }
182
+
183
+
184
+ def resolve_activation(activation):
185
+ # numpydoc ignore=GL08
186
+ name = activation.strip().lower()
187
+ try:
188
+ fn = ACTIVATIONS[name]
189
+ except KeyError as e:
190
+ allowed = sorted(ACTIVATIONS.keys())
191
+ raise ValueError(
192
+ f"activation='{activation}' is not supported; choose from {allowed}"
193
+ ) from e
194
+ return name, fn