netloader 3.11.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.
Files changed (41) hide show
  1. netloader-3.11.0/LICENSE.txt +21 -0
  2. netloader-3.11.0/PKG-INFO +59 -0
  3. netloader-3.11.0/README.md +36 -0
  4. netloader-3.11.0/netloader/__init__.py +61 -0
  5. netloader-3.11.0/netloader/architectures/__init__.py +48 -0
  6. netloader-3.11.0/netloader/architectures/base.py +1350 -0
  7. netloader-3.11.0/netloader/architectures/encoder_decoder.py +630 -0
  8. netloader-3.11.0/netloader/architectures/flows.py +501 -0
  9. netloader-3.11.0/netloader/architectures/utils.py +179 -0
  10. netloader-3.11.0/netloader/data.py +1092 -0
  11. netloader-3.11.0/netloader/layers/__init__.py +88 -0
  12. netloader-3.11.0/netloader/layers/base.py +367 -0
  13. netloader-3.11.0/netloader/layers/blocks.py +145 -0
  14. netloader-3.11.0/netloader/layers/convolutional.py +1008 -0
  15. netloader-3.11.0/netloader/layers/flows.py +123 -0
  16. netloader-3.11.0/netloader/layers/linear.py +445 -0
  17. netloader-3.11.0/netloader/layers/misc.py +879 -0
  18. netloader-3.11.0/netloader/layers/multi_layer.py +470 -0
  19. netloader-3.11.0/netloader/layers/pooling.py +298 -0
  20. netloader-3.11.0/netloader/layers/recurrent.py +163 -0
  21. netloader-3.11.0/netloader/layers/utils.py +168 -0
  22. netloader-3.11.0/netloader/loss_funcs.py +201 -0
  23. netloader-3.11.0/netloader/models/__init__.py +22 -0
  24. netloader-3.11.0/netloader/models/convnext.py +582 -0
  25. netloader-3.11.0/netloader/models/misc.py +209 -0
  26. netloader-3.11.0/netloader/network.py +895 -0
  27. netloader-3.11.0/netloader/networks/__init__.py +48 -0
  28. netloader-3.11.0/netloader/schedulers.py +409 -0
  29. netloader-3.11.0/netloader/transforms.py +847 -0
  30. netloader-3.11.0/netloader/utils/__init__.py +46 -0
  31. netloader-3.11.0/netloader/utils/configs.py +241 -0
  32. netloader-3.11.0/netloader/utils/transforms.py +22 -0
  33. netloader-3.11.0/netloader/utils/types.py +130 -0
  34. netloader-3.11.0/netloader/utils/utils.py +677 -0
  35. netloader-3.11.0/netloader.egg-info/PKG-INFO +59 -0
  36. netloader-3.11.0/netloader.egg-info/SOURCES.txt +39 -0
  37. netloader-3.11.0/netloader.egg-info/dependency_links.txt +1 -0
  38. netloader-3.11.0/netloader.egg-info/requires.txt +9 -0
  39. netloader-3.11.0/netloader.egg-info/top_level.txt +1 -0
  40. netloader-3.11.0/pyproject.toml +39 -0
  41. netloader-3.11.0/setup.cfg +4 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Ethan Tregidga
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,59 @@
1
+ Metadata-Version: 2.4
2
+ Name: netloader
3
+ Version: 3.11.0
4
+ Summary: Utility to generate and train PyTorch neural network objects from JSON files
5
+ Author-email: Ethan Tregidga <ethan.tregidga@epfl.ch>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/EthanTreg/PyTorch-Network-Loader
8
+ Project-URL: Issues, https://github.com/EthanTreg/PyTorch-Network-Loader/issues
9
+ Project-URL: ReadTheDocs, https://pytorch-network-loader.readthedocs.io/en/latest/
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.12
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE.txt
15
+ Requires-Dist: numpy>=2.4.0
16
+ Requires-Dist: torch>=2.11.0
17
+ Requires-Dist: packaging>=24.0
18
+ Provides-Extra: flows
19
+ Requires-Dist: zuko; extra == "flows"
20
+ Provides-Extra: wandb
21
+ Requires-Dist: wandb; extra == "wandb"
22
+ Dynamic: license-file
23
+
24
+ # PyTorch Network Loader
25
+
26
+ PyTorch Network Loader is a utility that enables the easy creation of neural networks in PyTorch using JSON
27
+ configuration files.
28
+ The package automatically tracks layer output shapes, eliminating the need to manually calculate input dimensions for
29
+ each layer.
30
+ NetLoader also provides an architecture framework that allows for the easy architecture setup and training framework,
31
+ along with additional useful utilities to accelerate the use of neural networks in science.
32
+
33
+ See the [Wiki](https://pytorch-network-loader.readthedocs.io) for more information on how to use this package.
34
+ For a real-world example of this package, see [Bayesian-DARKSKIES](https://github.com/EthanTreg/Bayesian-DARKSKIES).
35
+
36
+ ## Requirements
37
+
38
+ ### Using Within Projects
39
+
40
+ - pip install `netloader @ git+https://github.com/EthanTreg/PyTorch-Network-Loader@LATEST-VERSION`[^1] to
41
+ `requirements.txt`
42
+ - Install using `pip install -r requirements.txt`
43
+ - Example of [InceptionV4](https://arxiv.org/abs/1602.07261) can be downloaded under
44
+ `./network_configs/inceptionv4.json` along with the composite layers in
45
+ `./network_configs/composite_layers/`
46
+
47
+ [^1]: To use normalising flows or weights & biases, `netloader` must be pip installed with the optional argument
48
+ `flows` and/or `wandb`:
49
+ `pip install netloader[flows] @ git+https://github.com/EthanTreg/PyTorch-Network-Loader@LATEST-VERSION`
50
+
51
+ ### Locally Running NetLoader
52
+
53
+ - Clone or download the repository
54
+ - Install dependencies:
55
+ `pip install -r requirements.txt`
56
+ - PyTorch's dependencies[^2]:
57
+ NVIDIA GPU with [CUDA Toolkit](https://developer.nvidia.com/cuda-toolkit-archive) ~= v12.1
58
+ [^2]: Only required for use with NVIDIA GPU, v11.8 is also supported, but requirements.txt will
59
+ try to install the v12.1 version
@@ -0,0 +1,36 @@
1
+ # PyTorch Network Loader
2
+
3
+ PyTorch Network Loader is a utility that enables the easy creation of neural networks in PyTorch using JSON
4
+ configuration files.
5
+ The package automatically tracks layer output shapes, eliminating the need to manually calculate input dimensions for
6
+ each layer.
7
+ NetLoader also provides an architecture framework that allows for the easy architecture setup and training framework,
8
+ along with additional useful utilities to accelerate the use of neural networks in science.
9
+
10
+ See the [Wiki](https://pytorch-network-loader.readthedocs.io) for more information on how to use this package.
11
+ For a real-world example of this package, see [Bayesian-DARKSKIES](https://github.com/EthanTreg/Bayesian-DARKSKIES).
12
+
13
+ ## Requirements
14
+
15
+ ### Using Within Projects
16
+
17
+ - pip install `netloader @ git+https://github.com/EthanTreg/PyTorch-Network-Loader@LATEST-VERSION`[^1] to
18
+ `requirements.txt`
19
+ - Install using `pip install -r requirements.txt`
20
+ - Example of [InceptionV4](https://arxiv.org/abs/1602.07261) can be downloaded under
21
+ `./network_configs/inceptionv4.json` along with the composite layers in
22
+ `./network_configs/composite_layers/`
23
+
24
+ [^1]: To use normalising flows or weights & biases, `netloader` must be pip installed with the optional argument
25
+ `flows` and/or `wandb`:
26
+ `pip install netloader[flows] @ git+https://github.com/EthanTreg/PyTorch-Network-Loader@LATEST-VERSION`
27
+
28
+ ### Locally Running NetLoader
29
+
30
+ - Clone or download the repository
31
+ - Install dependencies:
32
+ `pip install -r requirements.txt`
33
+ - PyTorch's dependencies[^2]:
34
+ NVIDIA GPU with [CUDA Toolkit](https://developer.nvidia.com/cuda-toolkit-archive) ~= v12.1
35
+ [^2]: Only required for use with NVIDIA GPU, v11.8 is also supported, but requirements.txt will
36
+ try to install the v12.1 version
@@ -0,0 +1,61 @@
1
+ """
2
+ Package information, creates the logger and adds netloader classes to PyTorch safe globals
3
+ """
4
+ import sys
5
+ import logging
6
+ import warnings
7
+
8
+
9
+ __version__ = '3.11.0'
10
+ __author__ = 'Ethan Tregidga'
11
+ logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.WARNING)
12
+ warnings.filterwarnings('once', category=DeprecationWarning, module=r'^netloader(\.|$)')
13
+ warnings.filterwarnings(
14
+ 'once',
15
+ category=PendingDeprecationWarning,
16
+ module=r'^netloader(\.|$)',
17
+ )
18
+
19
+
20
+ if sys.version_info < (3, 12):
21
+ warnings.warn(
22
+ f'Python version ({sys.version_info.major}.{sys.version_info.minor}) is '
23
+ f'deprecated, please upgrade to Python 3.12 or higher',
24
+ DeprecationWarning,
25
+ )
26
+
27
+ try:
28
+ import torch
29
+
30
+ from netloader.utils import safe_globals
31
+ from netloader import (
32
+ layers,
33
+ models,
34
+ architectures,
35
+ utils,
36
+ data,
37
+ loss_funcs,
38
+ network,
39
+ schedulers,
40
+ transforms,
41
+ )
42
+
43
+
44
+ # Adds PyTorch Network Loader classes to list of safe PyTorch classes when loading saved
45
+ # architectures
46
+ safe_globals(__name__, [models, architectures, loss_funcs, schedulers, transforms])
47
+ torch.serialization.add_safe_globals([network.Network, network.CompatibleNetwork])
48
+
49
+ __all__ = [
50
+ 'utils',
51
+ 'layers',
52
+ 'models',
53
+ 'architectures',
54
+ 'data',
55
+ 'network',
56
+ 'loss_funcs',
57
+ 'schedulers',
58
+ 'transforms',
59
+ ]
60
+ except (ModuleNotFoundError, ImportError):
61
+ pass
@@ -0,0 +1,48 @@
1
+ """
2
+ Collects all architectures
3
+ """
4
+ from typing import Any
5
+ from warnings import warn
6
+
7
+ from netloader.architectures.utils import UtilityMixin
8
+ from netloader.architectures.base import BaseArchitecture, load_arch
9
+ from netloader.architectures.encoder_decoder import Autoencoder, Decoder, Encoder
10
+
11
+
12
+ __all__ = [
13
+ 'BaseArchitecture',
14
+ 'UtilityMixin',
15
+ 'Autoencoder',
16
+ 'Decoder',
17
+ 'Encoder',
18
+ 'load_arch',
19
+ ]
20
+
21
+ _optional_imports: dict[str, set[str]] = {'flow': {'NormFlow', 'NormFlowEncoder'}}
22
+
23
+ try:
24
+ from netloader.architectures.flows import NormFlow, NormFlowEncoder
25
+ __all__.extend(_optional_imports['flow'])
26
+ except (ModuleNotFoundError, ImportError) as e:
27
+ pass
28
+
29
+
30
+ def __getattr__(name: str) -> Any:
31
+ if name == 'BaseNetwork':
32
+ warn(
33
+ 'BaseNetwork is deprecated, please use BaseArchitecture instead',
34
+ DeprecationWarning,
35
+ stacklevel=2,
36
+ )
37
+ return BaseArchitecture
38
+ if name == 'load_net':
39
+ warn(
40
+ 'load_net is deprecated, please use load_arch instead',
41
+ DeprecationWarning,
42
+ stacklevel=2,
43
+ )
44
+ return load_arch
45
+ if name not in __all__ and name in _optional_imports['flow']:
46
+ raise ImportError(f'Cannot import {name}, normalising flow architectures require the '
47
+ f'package Zuko')
48
+ raise AttributeError(f"module {__name__} has no attribute {name}")