Commit ec686d9
authored
feat(mathy): cleanup and remove dead code
Mathy had experimental agents and code that were hard to maintain and reduced clarity with the package. Remove all but a single agent (A3C) and refactor the models to use the keras functional API.
* feat(a3c): replace LSTM with SIREN layers
- add time feature back (to help the value function predict end-of-episode variance in values)
- remove LSTMs and self-attention mechanism from embedding layer
- add Sin activated dense layers for inputs, and feed them into a SIREN layer at the end.
- replace PolicyValueReward heads with SIREN layers
NOTE: The SIREN model trains atleast as well as the LSTMs with self-attention, and is much smaller/faster on CPU.
* feat(episode_memory): add to_window_observations
- for computing windows of (n) size with (s) stride over the entire EpisodeMemory state. This can be used to turn terminal episode sequences into smalle n-step windows for training.
- allows dropping partial windows (e.g. at the end of the episode)
- allows zipping the output with any other keys in the EpisodeMemory class
- allows including an extra iterable of the same length as the EpisodeMemory to be zipped with the windows.
* chore(zero): drop zero agent and related code
BREAKING CHANGE: This removes the MCTS powered agent. It was a nice agent but the pieces required for it to work effectively have been lost. It's not a primary use-case of mine now, so it's better to drop it and remove any confusion.
* refactor(agents): move to singular agent with generic names
- PolicyValueModel -> AgentModel
- Remove embeddings model and make it part of AgentModel
* refactor(model): replace custom keras model with functional
- allows graphing model architecture for website
- adds extra validation
- allows full-model saving (without explicit optimizer save/loading)
* refactor(model): move action masking out of the model
- Soooo masking doesn't play well with full-model saving and loading, or functional models, or keras strict data validation. Drop it out of the model, and let the action selector do its own masking.
- TODO: add a loss term for the mask in addition to the policy loss?
* chore: misc cleanup and fix tests
* chore: update tf_siren dep
* chore: fix some tests and remove dead ones
* refactor(core): use mathy_core for CAS needs
This moves a lot of complexity out to another package, which is desirable for a number of reasons:
- when you only need to do CAS things, the mathy_core package can be installed without the need for larger things like TensorFlow or PyTorch which can make the install time much quicker
- the build time for the Mathy repo goes down by however much time it took to compile and test the core mathy code.
- it's easier to browse the code if you're unfamiliar with Mathy because it's not buried in a monorepo under a mountain of other folders
* chore: fix website build
* perf(ci): refactor virtual envs to reduce build time
- share a root virtualenv to avoid double or triple installing hefty packages like TensorFlow and PyTorch
* chore: remove ci specific setup script
* chore: remove disk space cleanup step
- it takes about a minute, and it's unclear if it's needed now that we share a root virtual env
* chore: drop keras-self-attention dep
* chore: fix requirements for tf agent
* chore: fix requirements for mkdocs plugin
* chore: install graphviz on ci build machine
* chore: try tensorflow 2.2.0
- I think this caused optimizer loading problems last time I tried to upgrade, but let's see
* chore: fix import errors
* chore: try to confirm siren fix
* chore: remove kwargs from Sine layer
* chore: remove second pytest invocation for zero
- TensorFlow didn't mix too well with multiprocessing so I had to run the MP tests separately for the Zero agent.
- Zero agent is gone, cya extra test invocation
* chore: fix venv path in test scripts
* chore: drop example apps from main package
- will add them later as mathy org repositories
- update API docs
- drop some unused queues
* chore: drop reformer test
* chore: bump tf_siren to 0.0.5 for tf2.2
* chore: drop misc cleanup
* test(cli): better coverage for generating problems
* chore: cleanup from review
* chore: cleanup from review
BREAKING CHANGES: This removes the "zero" agent entirely, and invalidates existing pretrained mathy models.1 parent 39f7a6b commit ec686d9
File tree
235 files changed
+2723
-13315
lines changed- .github/workflows
- libraries
- mathy_alpha_sm
- mathy_alpha_sm
- model
- variables
- tools
- mathy_mkdocs
- mathy_mkdocs
- tools
- mathy_python
- mathy
- agents
- a3c
- trfl
- zero
- lib
- progress
- agent
- trfl
- core
- envs
- gym
- rules
- swarm
- tests
- api
- fixtures
- rules
- test_model_sm
- model
- variables
- tools
- website
- docs
- api
- agent
- core
- examples
- img
- ml
- snippets
- cas
- envs
- examples
- ml
- tests
- examples
- ml
- tools
- tools
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
235 files changed
+2723
-13315
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 16 | + | |
| 17 | + | |
24 | 18 | | |
25 | | - | |
| 19 | + | |
26 | 20 | | |
27 | 21 | | |
28 | 22 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
Lines changed: 45 additions & 52 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
16 | 15 | | |
17 | | - | |
18 | 16 | | |
19 | | - | |
20 | | - | |
| 17 | + | |
21 | 18 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
57 | 50 | | |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
0 commit comments