neurz 0.0.2__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 (45) hide show
  1. neurz-0.0.2/LICENSE +24 -0
  2. neurz-0.0.2/PKG-INFO +139 -0
  3. neurz-0.0.2/README.md +114 -0
  4. neurz-0.0.2/pyproject.toml +44 -0
  5. neurz-0.0.2/setup.cfg +4 -0
  6. neurz-0.0.2/src/neurz/__init__.py +1 -0
  7. neurz-0.0.2/src/neurz/__main__.py +3 -0
  8. neurz-0.0.2/src/neurz/assets/__init__.py +0 -0
  9. neurz-0.0.2/src/neurz/assets/fonts/Inter-Medium.ttf +0 -0
  10. neurz-0.0.2/src/neurz/assets/fonts/Inter-OFL.txt +92 -0
  11. neurz-0.0.2/src/neurz/assets/fonts/Inter-Regular.ttf +0 -0
  12. neurz-0.0.2/src/neurz/assets/fonts/Inter-SemiBold.ttf +0 -0
  13. neurz-0.0.2/src/neurz/assets/fonts/InterDisplay-SemiBold.ttf +0 -0
  14. neurz-0.0.2/src/neurz/assets/fonts/JetBrainsMono-Medium.ttf +0 -0
  15. neurz-0.0.2/src/neurz/assets/fonts/JetBrainsMono-OFL.txt +93 -0
  16. neurz-0.0.2/src/neurz/assets/fonts/JetBrainsMono-Regular.ttf +0 -0
  17. neurz-0.0.2/src/neurz/cli.py +94 -0
  18. neurz-0.0.2/src/neurz/core/__init__.py +0 -0
  19. neurz-0.0.2/src/neurz/core/data.py +108 -0
  20. neurz-0.0.2/src/neurz/core/glossary.py +424 -0
  21. neurz-0.0.2/src/neurz/core/i18n.py +252 -0
  22. neurz-0.0.2/src/neurz/core/models.py +302 -0
  23. neurz-0.0.2/src/neurz/core/trace.py +89 -0
  24. neurz-0.0.2/src/neurz/core/weights.json +620 -0
  25. neurz-0.0.2/src/neurz/gui/__init__.py +0 -0
  26. neurz-0.0.2/src/neurz/gui/app.py +24 -0
  27. neurz-0.0.2/src/neurz/gui/main_window.py +713 -0
  28. neurz-0.0.2/src/neurz/gui/player.py +119 -0
  29. neurz-0.0.2/src/neurz/gui/theme.py +167 -0
  30. neurz-0.0.2/src/neurz/gui/views/__init__.py +0 -0
  31. neurz-0.0.2/src/neurz/gui/views/base.py +436 -0
  32. neurz-0.0.2/src/neurz/gui/views/cell_view.py +302 -0
  33. neurz-0.0.2/src/neurz/gui/views/cnn_view.py +242 -0
  34. neurz-0.0.2/src/neurz/gui/views/rnn_view.py +160 -0
  35. neurz-0.0.2/src/neurz/gui/widgets.py +270 -0
  36. neurz-0.0.2/src/neurz/settings.py +60 -0
  37. neurz-0.0.2/src/neurz.egg-info/PKG-INFO +139 -0
  38. neurz-0.0.2/src/neurz.egg-info/SOURCES.txt +43 -0
  39. neurz-0.0.2/src/neurz.egg-info/dependency_links.txt +1 -0
  40. neurz-0.0.2/src/neurz.egg-info/entry_points.txt +3 -0
  41. neurz-0.0.2/src/neurz.egg-info/requires.txt +5 -0
  42. neurz-0.0.2/src/neurz.egg-info/top_level.txt +1 -0
  43. neurz-0.0.2/tests/test_cli_gui.py +57 -0
  44. neurz-0.0.2/tests/test_core.py +120 -0
  45. neurz-0.0.2/tests/test_ports.py +29 -0
neurz-0.0.2/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bayram Kotan
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.
22
+
23
+ The bundled fonts in src/neurz/assets/fonts (Inter, JetBrains Mono) are
24
+ distributed under the SIL Open Font License 1.1; see the OFL files there.
neurz-0.0.2/PKG-INFO ADDED
@@ -0,0 +1,139 @@
1
+ Metadata-Version: 2.4
2
+ Name: neurz
3
+ Version: 0.0.2
4
+ Summary: See RNN, LSTM, GRU and CNN work step by step: an educational neural network visualiser with play, pause, step and scrub.
5
+ Author: Bayram Kotan
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/bayramkotan/neurz
8
+ Project-URL: Issues, https://github.com/bayramkotan/neurz/issues
9
+ Keywords: neural network,rnn,lstm,gru,cnn,education,visualization,deep learning,pyside6
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Intended Audience :: Education
14
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
15
+ Classifier: Topic :: Education
16
+ Classifier: Environment :: X11 Applications :: Qt
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: PySide6>=6.6
21
+ Requires-Dist: numpy>=1.24
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest>=7; extra == "dev"
24
+ Dynamic: license-file
25
+
26
+ # neurz
27
+
28
+ **See RNN, LSTM, GRU and CNN work, one operation at a time.**
29
+
30
+ neurz is an educational desktop app that runs small neural networks with real NumPy
31
+ arithmetic, records every operation and lets you play, pause, step and scrub through
32
+ them like a video. Every number on screen is the number the network actually computed;
33
+ every box, gate, wire and matrix can be clicked for an explanation in plain language,
34
+ in detail or as a formula.
35
+
36
+ ![LSTM forget gate](docs/lstm.png)
37
+
38
+ ## What you can watch
39
+
40
+ | Model | Task | What is animated |
41
+ |---|---|---|
42
+ | **RNN** | reads `n e u r` and predicts the next letter (`e u r z`) | the network unrolled in time: input, `W_xh·x`, `W_hh·h`, sum + bias, tanh, softmax |
43
+ | **LSTM** | same task | forget / input / output gates, candidate memory, the cell-state highway, `f ⊙ c + i ⊙ c̃`, `o ⊙ tanh(c)` |
44
+ | **GRU** | same task | reset and update gates, `r ⊙ h`, the candidate, the `(1 − z)·h + z·h̃` mix |
45
+ | **CNN** | is this 8×8 picture a vertical bar, a horizontal bar or a plus? | the 3×3 window sliding over the image, `x ⊙ K` and its sum, feature maps filling cell by cell, ReLU, max-pooling with the chosen maximum marked, flatten, dense, softmax |
46
+
47
+ ![CNN convolution](docs/cnn.png)
48
+
49
+ - **Playback:** play / pause, step forward and back, jump to start or end, loop, speed 0.25×–8×, a timeline grouped by time step that you can click or drag.
50
+ - **Click to learn:** clicking any element opens a short bubble next to it; the panel on the right explains it at three levels (Simple · Detailed · Math) with links to related concepts.
51
+ - **"Now" card:** what the current step does, the operation with its own numbers, and whether the guess was right.
52
+ - **Trained vs. random weights:** switch to an untrained network (any seed) and watch the predictions and the loss fall apart.
53
+ - Turkish and English interface, Night and Paper themes, keyboard shortcuts, settings remembered between runs.
54
+
55
+ ## Install
56
+
57
+ The desktop app (Python, PyPI):
58
+
59
+ ```bash
60
+ pip install neurz
61
+ neurz # or: nz
62
+ ```
63
+
64
+ Python 3.10+ with PySide6 and NumPy; runs on Windows, Linux and macOS.
65
+
66
+ The same runs, step by step in the terminal or in your own code, without the window:
67
+
68
+ ```bash
69
+ npm install -g neurz # JavaScript (npm)
70
+ neurz run lstm
71
+
72
+ cargo install neurz # Rust (crates.io)
73
+ neurz run cnn --sample plus
74
+ ```
75
+
76
+ ```js
77
+ import { run } from "neurz";
78
+ const r = run("gru"); // r.steps: [{ phase, t, formula }], r.guesses, r.loss
79
+ ```
80
+
81
+ ```rust
82
+ let r = neurz::run("lstm", "").unwrap(); // r.steps, r.guesses, r.loss
83
+ ```
84
+
85
+ All three packages are called `neurz` and share the same trained weights;
86
+ `neurz gui` in the npm and Rust versions opens the Python desktop app if it is installed.
87
+
88
+ ## Command line
89
+
90
+ ```bash
91
+ nz -V # version
92
+ nz models # list the models
93
+ nz run lstm # print every step with its numbers
94
+ nz run rnn --random --seed 3 # the same with untrained weights
95
+ nz run cnn --sample vertical
96
+ nz concepts # every concept key
97
+ nz explain forget_gate --level math
98
+ nz update # upgrade with this Python's pip
99
+ ```
100
+
101
+ ## Keyboard
102
+
103
+ | Key | Action |
104
+ |---|---|
105
+ | Space | play / pause |
106
+ | → / ← | step forward / back |
107
+ | Home / End | start / end |
108
+ | + / − | faster / slower |
109
+ | L | loop |
110
+ | 1 2 3 4 | RNN · LSTM · GRU · CNN |
111
+ | F1 F2 F3 | Simple · Detailed · Math explanation |
112
+
113
+ ## How it works
114
+
115
+ `neurz.core` has no Qt in it. Each model runs once (`core/models.py`) and writes every
116
+ operation down as a frame: which elements are active, along which wires the data moves,
117
+ every vector known so far and the formula with its numbers. The GUI player only moves
118
+ through these frames, so stepping back never recomputes anything. The trained weights
119
+ in `core/weights.json` come from `tools/train_weights.py`, which trains the tiny
120
+ networks with plain finite-difference gradients, no deep-learning library needed.
121
+
122
+ ## Development
123
+
124
+ ```bash
125
+ git clone https://github.com/bayramkotan/neurz
126
+ cd neurz
127
+ pip install -e .[dev]
128
+ pytest # Python
129
+ npm test # JavaScript (js/)
130
+ cargo test # Rust (rust/)
131
+ ```
132
+
133
+ Pushing a `vX.Y.Z` tag runs `.github/workflows/release.yml`: the tests of all three
134
+ languages, then PyPI, npm and crates.io in one run (secrets: `PYPI_API_TOKEN`,
135
+ `NPM_TOKEN`, `CARGO_REGISTRY_TOKEN`).
136
+
137
+ ## License
138
+
139
+ MIT. Bundled fonts: Inter and JetBrains Mono (SIL Open Font License 1.1).
neurz-0.0.2/README.md ADDED
@@ -0,0 +1,114 @@
1
+ # neurz
2
+
3
+ **See RNN, LSTM, GRU and CNN work, one operation at a time.**
4
+
5
+ neurz is an educational desktop app that runs small neural networks with real NumPy
6
+ arithmetic, records every operation and lets you play, pause, step and scrub through
7
+ them like a video. Every number on screen is the number the network actually computed;
8
+ every box, gate, wire and matrix can be clicked for an explanation in plain language,
9
+ in detail or as a formula.
10
+
11
+ ![LSTM forget gate](docs/lstm.png)
12
+
13
+ ## What you can watch
14
+
15
+ | Model | Task | What is animated |
16
+ |---|---|---|
17
+ | **RNN** | reads `n e u r` and predicts the next letter (`e u r z`) | the network unrolled in time: input, `W_xh·x`, `W_hh·h`, sum + bias, tanh, softmax |
18
+ | **LSTM** | same task | forget / input / output gates, candidate memory, the cell-state highway, `f ⊙ c + i ⊙ c̃`, `o ⊙ tanh(c)` |
19
+ | **GRU** | same task | reset and update gates, `r ⊙ h`, the candidate, the `(1 − z)·h + z·h̃` mix |
20
+ | **CNN** | is this 8×8 picture a vertical bar, a horizontal bar or a plus? | the 3×3 window sliding over the image, `x ⊙ K` and its sum, feature maps filling cell by cell, ReLU, max-pooling with the chosen maximum marked, flatten, dense, softmax |
21
+
22
+ ![CNN convolution](docs/cnn.png)
23
+
24
+ - **Playback:** play / pause, step forward and back, jump to start or end, loop, speed 0.25×–8×, a timeline grouped by time step that you can click or drag.
25
+ - **Click to learn:** clicking any element opens a short bubble next to it; the panel on the right explains it at three levels (Simple · Detailed · Math) with links to related concepts.
26
+ - **"Now" card:** what the current step does, the operation with its own numbers, and whether the guess was right.
27
+ - **Trained vs. random weights:** switch to an untrained network (any seed) and watch the predictions and the loss fall apart.
28
+ - Turkish and English interface, Night and Paper themes, keyboard shortcuts, settings remembered between runs.
29
+
30
+ ## Install
31
+
32
+ The desktop app (Python, PyPI):
33
+
34
+ ```bash
35
+ pip install neurz
36
+ neurz # or: nz
37
+ ```
38
+
39
+ Python 3.10+ with PySide6 and NumPy; runs on Windows, Linux and macOS.
40
+
41
+ The same runs, step by step in the terminal or in your own code, without the window:
42
+
43
+ ```bash
44
+ npm install -g neurz # JavaScript (npm)
45
+ neurz run lstm
46
+
47
+ cargo install neurz # Rust (crates.io)
48
+ neurz run cnn --sample plus
49
+ ```
50
+
51
+ ```js
52
+ import { run } from "neurz";
53
+ const r = run("gru"); // r.steps: [{ phase, t, formula }], r.guesses, r.loss
54
+ ```
55
+
56
+ ```rust
57
+ let r = neurz::run("lstm", "").unwrap(); // r.steps, r.guesses, r.loss
58
+ ```
59
+
60
+ All three packages are called `neurz` and share the same trained weights;
61
+ `neurz gui` in the npm and Rust versions opens the Python desktop app if it is installed.
62
+
63
+ ## Command line
64
+
65
+ ```bash
66
+ nz -V # version
67
+ nz models # list the models
68
+ nz run lstm # print every step with its numbers
69
+ nz run rnn --random --seed 3 # the same with untrained weights
70
+ nz run cnn --sample vertical
71
+ nz concepts # every concept key
72
+ nz explain forget_gate --level math
73
+ nz update # upgrade with this Python's pip
74
+ ```
75
+
76
+ ## Keyboard
77
+
78
+ | Key | Action |
79
+ |---|---|
80
+ | Space | play / pause |
81
+ | → / ← | step forward / back |
82
+ | Home / End | start / end |
83
+ | + / − | faster / slower |
84
+ | L | loop |
85
+ | 1 2 3 4 | RNN · LSTM · GRU · CNN |
86
+ | F1 F2 F3 | Simple · Detailed · Math explanation |
87
+
88
+ ## How it works
89
+
90
+ `neurz.core` has no Qt in it. Each model runs once (`core/models.py`) and writes every
91
+ operation down as a frame: which elements are active, along which wires the data moves,
92
+ every vector known so far and the formula with its numbers. The GUI player only moves
93
+ through these frames, so stepping back never recomputes anything. The trained weights
94
+ in `core/weights.json` come from `tools/train_weights.py`, which trains the tiny
95
+ networks with plain finite-difference gradients, no deep-learning library needed.
96
+
97
+ ## Development
98
+
99
+ ```bash
100
+ git clone https://github.com/bayramkotan/neurz
101
+ cd neurz
102
+ pip install -e .[dev]
103
+ pytest # Python
104
+ npm test # JavaScript (js/)
105
+ cargo test # Rust (rust/)
106
+ ```
107
+
108
+ Pushing a `vX.Y.Z` tag runs `.github/workflows/release.yml`: the tests of all three
109
+ languages, then PyPI, npm and crates.io in one run (secrets: `PYPI_API_TOKEN`,
110
+ `NPM_TOKEN`, `CARGO_REGISTRY_TOKEN`).
111
+
112
+ ## License
113
+
114
+ MIT. Bundled fonts: Inter and JetBrains Mono (SIL Open Font License 1.1).
@@ -0,0 +1,44 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "neurz"
7
+ version = "0.0.2"
8
+ description = "See RNN, LSTM, GRU and CNN work step by step: an educational neural network visualiser with play, pause, step and scrub."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "Bayram Kotan" }]
13
+ keywords = ["neural network", "rnn", "lstm", "gru", "cnn", "education", "visualization", "deep learning", "pyside6"]
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ "Intended Audience :: Education",
19
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
20
+ "Topic :: Education",
21
+ "Environment :: X11 Applications :: Qt",
22
+ ]
23
+ dependencies = ["PySide6>=6.6", "numpy>=1.24"]
24
+
25
+ [project.optional-dependencies]
26
+ dev = ["pytest>=7"]
27
+
28
+ [project.urls]
29
+ Homepage = "https://github.com/bayramkotan/neurz"
30
+ Issues = "https://github.com/bayramkotan/neurz/issues"
31
+
32
+ [project.scripts]
33
+ neurz = "neurz.cli:main"
34
+ nz = "neurz.cli:main"
35
+
36
+ [tool.setuptools.packages.find]
37
+ where = ["src"]
38
+
39
+ [tool.setuptools.package-data]
40
+ "neurz.core" = ["weights.json"]
41
+ "neurz.assets" = ["fonts/*.ttf", "fonts/*.txt"]
42
+
43
+ [tool.pytest.ini_options]
44
+ testpaths = ["tests"]
neurz-0.0.2/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ __version__ = "0.0.2"
@@ -0,0 +1,3 @@
1
+ from .cli import main
2
+
3
+ raise SystemExit(main())
File without changes
@@ -0,0 +1,92 @@
1
+ Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+ -----------------------------------------------------------
8
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
9
+ -----------------------------------------------------------
10
+
11
+ PREAMBLE
12
+ The goals of the Open Font License (OFL) are to stimulate worldwide
13
+ development of collaborative font projects, to support the font creation
14
+ efforts of academic and linguistic communities, and to provide a free and
15
+ open framework in which fonts may be shared and improved in partnership
16
+ with others.
17
+
18
+ The OFL allows the licensed fonts to be used, studied, modified and
19
+ redistributed freely as long as they are not sold by themselves. The
20
+ fonts, including any derivative works, can be bundled, embedded,
21
+ redistributed and/or sold with any software provided that any reserved
22
+ names are not used by derivative works. The fonts and derivatives,
23
+ however, cannot be released under any other type of license. The
24
+ requirement for fonts to remain under this license does not apply
25
+ to any document created using the fonts or their derivatives.
26
+
27
+ DEFINITIONS
28
+ "Font Software" refers to the set of files released by the Copyright
29
+ Holder(s) under this license and clearly marked as such. This may
30
+ include source files, build scripts and documentation.
31
+
32
+ "Reserved Font Name" refers to any names specified as such after the
33
+ copyright statement(s).
34
+
35
+ "Original Version" refers to the collection of Font Software components as
36
+ distributed by the Copyright Holder(s).
37
+
38
+ "Modified Version" refers to any derivative made by adding to, deleting,
39
+ or substituting -- in part or in whole -- any of the components of the
40
+ Original Version, by changing formats or by porting the Font Software to a
41
+ new environment.
42
+
43
+ "Author" refers to any designer, engineer, programmer, technical
44
+ writer or other person who contributed to the Font Software.
45
+
46
+ PERMISSION AND CONDITIONS
47
+ Permission is hereby granted, free of charge, to any person obtaining
48
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
49
+ redistribute, and sell modified and unmodified copies of the Font
50
+ Software, subject to the following conditions:
51
+
52
+ 1) Neither the Font Software nor any of its individual components,
53
+ in Original or Modified Versions, may be sold by itself.
54
+
55
+ 2) Original or Modified Versions of the Font Software may be bundled,
56
+ redistributed and/or sold with any software, provided that each copy
57
+ contains the above copyright notice and this license. These can be
58
+ included either as stand-alone text files, human-readable headers or
59
+ in the appropriate machine-readable metadata fields within text or
60
+ binary files as long as those fields can be easily viewed by the user.
61
+
62
+ 3) No Modified Version of the Font Software may use the Reserved Font
63
+ Name(s) unless explicit written permission is granted by the corresponding
64
+ Copyright Holder. This restriction only applies to the primary font name as
65
+ presented to the users.
66
+
67
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
68
+ Software shall not be used to promote, endorse or advertise any
69
+ Modified Version, except to acknowledge the contribution(s) of the
70
+ Copyright Holder(s) and the Author(s) or with their explicit written
71
+ permission.
72
+
73
+ 5) The Font Software, modified or unmodified, in part or in whole,
74
+ must be distributed entirely under this license, and must not be
75
+ distributed under any other license. The requirement for fonts to
76
+ remain under this license does not apply to any document created
77
+ using the Font Software.
78
+
79
+ TERMINATION
80
+ This license becomes null and void if any of the above conditions are
81
+ not met.
82
+
83
+ DISCLAIMER
84
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
85
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
86
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
87
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
88
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
89
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
90
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
91
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
92
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,93 @@
1
+ Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ https://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,94 @@
1
+ """Command line: ``neurz`` / ``nz``.
2
+
3
+ No arguments opens the window. Subcommands work in a terminal:
4
+
5
+ nz models list the models
6
+ nz run lstm [--random --seed 3] print every step of a run with its numbers
7
+ nz run cnn --sample vertical
8
+ nz concepts list every concept key
9
+ nz explain forget_gate --level math
10
+ nz update upgrade neurz with this Python's pip
11
+ nz -v | -V | --version
12
+ """
13
+ from __future__ import annotations
14
+
15
+ import argparse
16
+ import re
17
+ import subprocess
18
+ import sys
19
+
20
+ from . import __version__
21
+
22
+ VERSION_FLAGS = {"-v", "-V", "--version", "--Version", "-version", "--v", "--V"}
23
+
24
+
25
+ def _plain(s: str) -> str:
26
+ s = s.replace("<br>", "\n").replace("<sub>", "").replace("</sub>", "").replace("<sup>", "^").replace("</sup>", "")
27
+ return re.sub(r"<[^>]+>", "", s)
28
+
29
+
30
+ def main(argv: list[str] | None = None) -> int:
31
+ argv = list(sys.argv[1:] if argv is None else argv)
32
+ if any(a in VERSION_FLAGS for a in argv):
33
+ print(f"neurz {__version__}")
34
+ return 0
35
+ if not argv or argv[0] == "gui":
36
+ from .gui.app import run
37
+ return run()
38
+
39
+ from .core import data, glossary, models
40
+ from .core.i18n import phase
41
+ from .settings import system_lang
42
+
43
+ ap = argparse.ArgumentParser(prog="neurz", description="Educational RNN / LSTM / GRU / CNN visualiser")
44
+ ap.add_argument("--lang", choices=["tr", "en"], default=None)
45
+ sub = ap.add_subparsers(dest="cmd")
46
+ sub.add_parser("models")
47
+ r = sub.add_parser("run")
48
+ r.add_argument("model", choices=models.MODELS)
49
+ r.add_argument("--random", action="store_true", help="untrained random weights")
50
+ r.add_argument("--seed", type=int, default=7)
51
+ r.add_argument("--sample", choices=data.CNN_CLASSES, default="plus")
52
+ sub.add_parser("concepts")
53
+ e = sub.add_parser("explain")
54
+ e.add_argument("concept")
55
+ e.add_argument("--level", choices=glossary.LEVELS, default="detail")
56
+ sub.add_parser("update")
57
+ args = ap.parse_args(argv)
58
+ lang = args.lang or system_lang()
59
+
60
+ if args.cmd == "models":
61
+ for m in models.MODELS:
62
+ print(f"{m:5s} {_plain(glossary.get(m, lang)['title'])}")
63
+ return 0
64
+ if args.cmd == "run":
65
+ tr = models.build(args.model, trained=not args.random, seed=args.seed, sample=args.sample)
66
+ word = tr.meta.get("word")
67
+ for k, fr in enumerate(tr.frames, 1):
68
+ kw = {"t": max(0, fr.t), "r": fr.extra.get("r", 0), "c": fr.extra.get("c", 0),
69
+ "ch": word[fr.t] if word and fr.t >= 0 else "", "nx": word[fr.t + 1] if word and fr.t >= 0 else ""}
70
+ title = phase(lang, fr.phase, **kw)[0]
71
+ print(f"{k:3d} {_plain(title):32s} {fr.formula}")
72
+ return 0
73
+ if args.cmd == "concepts":
74
+ for k in glossary.keys():
75
+ print(f"{k:20s} {_plain(glossary.get(k, lang)['title'])}")
76
+ return 0
77
+ if args.cmd == "explain":
78
+ try:
79
+ g = glossary.get(args.concept, lang)
80
+ except KeyError:
81
+ print(f"unknown concept: {args.concept} (see: neurz concepts)", file=sys.stderr)
82
+ return 2
83
+ print(_plain(g["title"]))
84
+ print()
85
+ print(_plain(g[args.level]))
86
+ return 0
87
+ if args.cmd == "update":
88
+ return subprocess.call([sys.executable, "-m", "pip", "install", "-U", "neurz"])
89
+ ap.print_help()
90
+ return 0
91
+
92
+
93
+ if __name__ == "__main__":
94
+ raise SystemExit(main())
File without changes