monitorch 0.0.1__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.
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2025, Maksym Khavil
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,100 @@
1
+ Metadata-Version: 2.4
2
+ Name: monitorch
3
+ Version: 0.0.1
4
+ Summary: A plug-and-use python library to monitor learning of PyTorch neural networks
5
+ Author-email: Maksym Khavil <mk.khavil@gmail.com>
6
+ License-Expression: BSD-3-Clause
7
+ Project-URL: Homepage, https://github.com/ZhigaMason/monitorch
8
+ Project-URL: Bug Tracker, https://github.com/ZhigaMason/monitorch/issues
9
+ Keywords: pytorch,visualization,neural networks,gradients
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: torch>=2.0.0
16
+ Requires-Dist: matplotlib>=3.10.0
17
+ Requires-Dist: tensorboard>=2.19.0
18
+ Dynamic: license-file
19
+
20
+ # Monitorch
21
+
22
+ A plug-and-use python module to monitor learning of PyTorch neural networks. Heavily inspired by [an article](https://ai.gopubby.com/better-ways-to-monitor-nns-while-training-7c246867ca4f) by Malcolm Lett. Provides easy to use interface to collect and display
23
+
24
+ - Loss and custom metrics
25
+ - Layer outputs (activation and norms)
26
+ - Gradients (norms, scalar products and activation)
27
+ - Neural Net's Parameters (norm)
28
+
29
+ Monitorch manages layer separation, data collection and vizualization with simple exposed methods and classes, so the code is concise and expressive without sacrificing informativness of the vizualizations and broad scope of its application. It also allows user to choose between static matplotlib and dynamic tensorboard plotting to help investigate both small models and keep track of large machines.
30
+
31
+ # Usage
32
+
33
+ ## Requirments
34
+
35
+ - python>=3.10
36
+ - torch>=2.0.0
37
+ - matplotlib>=3.10.0
38
+ - tensorboard>=2.19.0
39
+
40
+ ## Installation
41
+
42
+ Install the module using pip dependency manager.
43
+
44
+ ```{bash}
45
+ pip install monitorch
46
+ ```
47
+
48
+ ## Code
49
+
50
+ Use `PyTorchInspector` from `monitorch.inspector` to hook your module and lenses (for example `LossMetrics` or `ParameterGradientGeometry`) from `monitorch.lens` to define vizualizations.
51
+
52
+ ```{python}
53
+ import torch
54
+
55
+ from monitorch.inspector import PyTorchInspector
56
+ from monitorch.lens import LossMetrics, ParameterGradientGeometry
57
+
58
+ mynet = MyNeuralNet() # torch.nn.Module subclass
59
+ loss_fn = MSELoss()
60
+ optimizer = torch.optim.Adam(module.parameters())
61
+
62
+ inspector = PyTorchInspector(
63
+ lenses = [
64
+ LossMetrics(loss_fn=loss_fn),
65
+ ParameterGradientGeometry()
66
+ ],
67
+ module = mynet,
68
+ vizualizer = "matplotlib"
69
+ )
70
+
71
+ for epoch in range(n_epochs):
72
+ # No changes to your training loop
73
+ # Passes through training and validation datasets remain the same
74
+
75
+ ...
76
+
77
+ # at the end of an epoch inspector must be ticked
78
+ inspector.tick_epoch()
79
+
80
+ inspector.vizualizer.show_fig()
81
+ ```
82
+
83
+ You can choose other vizualizers by passing `"tensorboard"`, `"print"` or an instance of vizualizer's class from `monitorch.vizualizers`. Note that matplotlib vizualier requires `show_fig()` call to plot.
84
+
85
+ Currently module supports gradient and parameter collection for arbitrary PyTorch module and output collection for single output architectures (feedforward, convolution, non-transformer autoencoders etc).
86
+
87
+
88
+ ## Tests
89
+
90
+ Tests can be run with `pytest` from root project directory. Lens test have no assertions or other critical functionality tests, but are rather smoke tests to catch unhandled exceptions. To run functionality tests run `pytest -k "not smoke"`.
91
+
92
+ # TODO
93
+
94
+ - [ ] Documentation
95
+ - [ ] Setup sphinx
96
+ - [ ] Write docstrings
97
+ - [ ] Create demo notebooks
98
+ - [ ] Recurrent Neural Networks output collection
99
+ - [ ] Transformer output collection (value vector vs state vector)
100
+ - [ ] Debug Lens
@@ -0,0 +1,81 @@
1
+ # Monitorch
2
+
3
+ A plug-and-use python module to monitor learning of PyTorch neural networks. Heavily inspired by [an article](https://ai.gopubby.com/better-ways-to-monitor-nns-while-training-7c246867ca4f) by Malcolm Lett. Provides easy to use interface to collect and display
4
+
5
+ - Loss and custom metrics
6
+ - Layer outputs (activation and norms)
7
+ - Gradients (norms, scalar products and activation)
8
+ - Neural Net's Parameters (norm)
9
+
10
+ Monitorch manages layer separation, data collection and vizualization with simple exposed methods and classes, so the code is concise and expressive without sacrificing informativness of the vizualizations and broad scope of its application. It also allows user to choose between static matplotlib and dynamic tensorboard plotting to help investigate both small models and keep track of large machines.
11
+
12
+ # Usage
13
+
14
+ ## Requirments
15
+
16
+ - python>=3.10
17
+ - torch>=2.0.0
18
+ - matplotlib>=3.10.0
19
+ - tensorboard>=2.19.0
20
+
21
+ ## Installation
22
+
23
+ Install the module using pip dependency manager.
24
+
25
+ ```{bash}
26
+ pip install monitorch
27
+ ```
28
+
29
+ ## Code
30
+
31
+ Use `PyTorchInspector` from `monitorch.inspector` to hook your module and lenses (for example `LossMetrics` or `ParameterGradientGeometry`) from `monitorch.lens` to define vizualizations.
32
+
33
+ ```{python}
34
+ import torch
35
+
36
+ from monitorch.inspector import PyTorchInspector
37
+ from monitorch.lens import LossMetrics, ParameterGradientGeometry
38
+
39
+ mynet = MyNeuralNet() # torch.nn.Module subclass
40
+ loss_fn = MSELoss()
41
+ optimizer = torch.optim.Adam(module.parameters())
42
+
43
+ inspector = PyTorchInspector(
44
+ lenses = [
45
+ LossMetrics(loss_fn=loss_fn),
46
+ ParameterGradientGeometry()
47
+ ],
48
+ module = mynet,
49
+ vizualizer = "matplotlib"
50
+ )
51
+
52
+ for epoch in range(n_epochs):
53
+ # No changes to your training loop
54
+ # Passes through training and validation datasets remain the same
55
+
56
+ ...
57
+
58
+ # at the end of an epoch inspector must be ticked
59
+ inspector.tick_epoch()
60
+
61
+ inspector.vizualizer.show_fig()
62
+ ```
63
+
64
+ You can choose other vizualizers by passing `"tensorboard"`, `"print"` or an instance of vizualizer's class from `monitorch.vizualizers`. Note that matplotlib vizualier requires `show_fig()` call to plot.
65
+
66
+ Currently module supports gradient and parameter collection for arbitrary PyTorch module and output collection for single output architectures (feedforward, convolution, non-transformer autoencoders etc).
67
+
68
+
69
+ ## Tests
70
+
71
+ Tests can be run with `pytest` from root project directory. Lens test have no assertions or other critical functionality tests, but are rather smoke tests to catch unhandled exceptions. To run functionality tests run `pytest -k "not smoke"`.
72
+
73
+ # TODO
74
+
75
+ - [ ] Documentation
76
+ - [ ] Setup sphinx
77
+ - [ ] Write docstrings
78
+ - [ ] Create demo notebooks
79
+ - [ ] Recurrent Neural Networks output collection
80
+ - [ ] Transformer output collection (value vector vs state vector)
81
+ - [ ] Debug Lens
File without changes
@@ -0,0 +1,100 @@
1
+ Metadata-Version: 2.4
2
+ Name: monitorch
3
+ Version: 0.0.1
4
+ Summary: A plug-and-use python library to monitor learning of PyTorch neural networks
5
+ Author-email: Maksym Khavil <mk.khavil@gmail.com>
6
+ License-Expression: BSD-3-Clause
7
+ Project-URL: Homepage, https://github.com/ZhigaMason/monitorch
8
+ Project-URL: Bug Tracker, https://github.com/ZhigaMason/monitorch/issues
9
+ Keywords: pytorch,visualization,neural networks,gradients
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: torch>=2.0.0
16
+ Requires-Dist: matplotlib>=3.10.0
17
+ Requires-Dist: tensorboard>=2.19.0
18
+ Dynamic: license-file
19
+
20
+ # Monitorch
21
+
22
+ A plug-and-use python module to monitor learning of PyTorch neural networks. Heavily inspired by [an article](https://ai.gopubby.com/better-ways-to-monitor-nns-while-training-7c246867ca4f) by Malcolm Lett. Provides easy to use interface to collect and display
23
+
24
+ - Loss and custom metrics
25
+ - Layer outputs (activation and norms)
26
+ - Gradients (norms, scalar products and activation)
27
+ - Neural Net's Parameters (norm)
28
+
29
+ Monitorch manages layer separation, data collection and vizualization with simple exposed methods and classes, so the code is concise and expressive without sacrificing informativness of the vizualizations and broad scope of its application. It also allows user to choose between static matplotlib and dynamic tensorboard plotting to help investigate both small models and keep track of large machines.
30
+
31
+ # Usage
32
+
33
+ ## Requirments
34
+
35
+ - python>=3.10
36
+ - torch>=2.0.0
37
+ - matplotlib>=3.10.0
38
+ - tensorboard>=2.19.0
39
+
40
+ ## Installation
41
+
42
+ Install the module using pip dependency manager.
43
+
44
+ ```{bash}
45
+ pip install monitorch
46
+ ```
47
+
48
+ ## Code
49
+
50
+ Use `PyTorchInspector` from `monitorch.inspector` to hook your module and lenses (for example `LossMetrics` or `ParameterGradientGeometry`) from `monitorch.lens` to define vizualizations.
51
+
52
+ ```{python}
53
+ import torch
54
+
55
+ from monitorch.inspector import PyTorchInspector
56
+ from monitorch.lens import LossMetrics, ParameterGradientGeometry
57
+
58
+ mynet = MyNeuralNet() # torch.nn.Module subclass
59
+ loss_fn = MSELoss()
60
+ optimizer = torch.optim.Adam(module.parameters())
61
+
62
+ inspector = PyTorchInspector(
63
+ lenses = [
64
+ LossMetrics(loss_fn=loss_fn),
65
+ ParameterGradientGeometry()
66
+ ],
67
+ module = mynet,
68
+ vizualizer = "matplotlib"
69
+ )
70
+
71
+ for epoch in range(n_epochs):
72
+ # No changes to your training loop
73
+ # Passes through training and validation datasets remain the same
74
+
75
+ ...
76
+
77
+ # at the end of an epoch inspector must be ticked
78
+ inspector.tick_epoch()
79
+
80
+ inspector.vizualizer.show_fig()
81
+ ```
82
+
83
+ You can choose other vizualizers by passing `"tensorboard"`, `"print"` or an instance of vizualizer's class from `monitorch.vizualizers`. Note that matplotlib vizualier requires `show_fig()` call to plot.
84
+
85
+ Currently module supports gradient and parameter collection for arbitrary PyTorch module and output collection for single output architectures (feedforward, convolution, non-transformer autoencoders etc).
86
+
87
+
88
+ ## Tests
89
+
90
+ Tests can be run with `pytest` from root project directory. Lens test have no assertions or other critical functionality tests, but are rather smoke tests to catch unhandled exceptions. To run functionality tests run `pytest -k "not smoke"`.
91
+
92
+ # TODO
93
+
94
+ - [ ] Documentation
95
+ - [ ] Setup sphinx
96
+ - [ ] Write docstrings
97
+ - [ ] Create demo notebooks
98
+ - [ ] Recurrent Neural Networks output collection
99
+ - [ ] Transformer output collection (value vector vs state vector)
100
+ - [ ] Debug Lens
@@ -0,0 +1,9 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ monitorch/__init__.py
5
+ monitorch.egg-info/PKG-INFO
6
+ monitorch.egg-info/SOURCES.txt
7
+ monitorch.egg-info/dependency_links.txt
8
+ monitorch.egg-info/requires.txt
9
+ monitorch.egg-info/top_level.txt
@@ -0,0 +1,3 @@
1
+ torch>=2.0.0
2
+ matplotlib>=3.10.0
3
+ tensorboard>=2.19.0
@@ -0,0 +1 @@
1
+ monitorch
@@ -0,0 +1,42 @@
1
+ [project]
2
+ name = "monitorch"
3
+ version = "0.0.1"
4
+ description = "A plug-and-use python library to monitor learning of PyTorch neural networks"
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Maksym Khavil", email = "mk.khavil@gmail.com" }
8
+ ]
9
+ keywords = [
10
+ "pytorch",
11
+ "visualization",
12
+ "neural networks",
13
+ "gradients"
14
+ ]
15
+ license = "BSD-3-Clause"
16
+ classifiers = [
17
+ "Programming Language :: Python :: 3",
18
+ "Operating System :: OS Independent"
19
+ ]
20
+ requires-python = ">=3.10"
21
+
22
+ dependencies = [
23
+ "torch>=2.0.0",
24
+ "matplotlib>=3.10.0",
25
+ "tensorboard>=2.19.0"
26
+ ]
27
+
28
+ [project.urls]
29
+ "Homepage" = "https://github.com/ZhigaMason/monitorch"
30
+ "Bug Tracker" = "https://github.com/ZhigaMason/monitorch/issues"
31
+
32
+ [build-system]
33
+ requires = ["setuptools>=61.0", "wheel"]
34
+ build-backend = "setuptools.build_meta"
35
+
36
+ [tool.setuptools]
37
+ packages = ["monitorch"]
38
+
39
+ [tool.pytest.ini_options]
40
+ markers = [
41
+ "smoke: tests only succesful runs, no functionality asserts",
42
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+