Skip to content

Commit ec686d9

Browse files
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

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

.github/workflows/main.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,10 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v1
16-
# from: https://bit.ly/2yo0tXG
17-
- name: Free Disk Space
18-
run: |
19-
sudo swapoff -a
20-
sudo rm -f /swapfile
21-
sudo apt clean
22-
docker rmi $(docker image ls -aq)
23-
df -h
16+
- name: Install Graphviz
17+
run: sudo apt-get install graphviz
2418
- name: Setup Packages
25-
run: sh tools/ci-setup.sh
19+
run: sh tools/setup.sh
2620
- name: Build Packages
2721
run: sh tools/build.sh
2822
- name: Test Packages

.github/workflows/release.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ build
3131
coverage
3232

3333
libraries/website/site/
34+
35+
36+
.ipynb_checkpoints
Lines changed: 45 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,50 @@
11
{
2-
"name": "mathy_alpha_sm",
3-
"version": "0.7.14",
4-
"description": "Mathy.ai multi-task small model",
5-
"license": "CC BY-SA 3.0",
6-
"author": "Justin DuJardin",
7-
"email": "justin@dujardinconsulting.com",
8-
"url": "https://mathy.ai",
9-
"mathy_version": ">=0.6.7,<1.0.0",
10-
"prediction_window_size": 16,
11-
"dropout": 0.2,
12-
"units": 256,
13-
"embedding_units": 256,
14-
"lstm_units": 128,
15-
"topics": [
2+
"name":"unnamed_model",
3+
"version":"0.0.1",
4+
"description":"Mathy.ai trained model",
5+
"license":"CC BY-SA 3.0",
6+
"author":"Justin DuJardin",
7+
"email":"justin@dujardinconsulting.com",
8+
"url":"https://mathy.ai",
9+
"mathy_version":">=0.7.14,<1.0.0",
10+
"seq_len":256,
11+
"prediction_window_size":6,
12+
"units":256,
13+
"embedding_units":256,
14+
"topics":[
1615
"poly",
17-
"poly-combine",
1816
"complex",
19-
"binomial",
20-
"poly-blockers"
17+
"binomial"
2118
],
22-
"difficulty": null,
23-
"model_dir": "mathy_alpha_sm",
24-
"model_name": "model",
25-
"init_model_from": null,
26-
"train": false,
27-
"verbose": true,
28-
"lr_initial": 0.01,
29-
"lr_decay_steps": 100,
30-
"lr_decay_rate": 0.96,
31-
"lr_decay_staircase": true,
32-
"max_eps": 15000,
33-
"summary_interval": 100,
34-
"gamma": 0.99,
35-
"num_workers": 4,
36-
"td_lambda": 0.2,
37-
"print_training": false,
38-
"print_model_call_times": false,
39-
"print_mode": "terminal",
40-
"normalization_style": "layer",
41-
"update_gradients_every": 8,
42-
"mcts_sims": 10,
43-
"worker_wait": 0.01,
44-
"profile": false,
45-
"action_strategy": "a3c",
46-
"main_worker_use_epsilon": false,
47-
"e_greedy_min": 0.01,
48-
"e_greedy_max": 0.1,
49-
"entropy_loss_scaling": 0.05,
50-
"normalize_entropy_loss": true,
51-
"normalize_pi_loss": true,
52-
"aux_tasks_weight_scale": 1,
53-
"teacher_start_evaluations_at_episode": 50,
54-
"teacher_evaluation_steps": 20,
55-
"teacher_promote_wins": 0.95,
56-
"teacher_demote_wins": 0.5
19+
"difficulty":null,
20+
"model_dir":"training/mathy_alpha_sm",
21+
"model_name":"model",
22+
"verbose":false,
23+
"lr_initial":0.01,
24+
"lr_decay_steps":100,
25+
"lr_decay_rate":0.96,
26+
"lr_decay_staircase":true,
27+
"max_eps":15000,
28+
"summary_interval":100,
29+
"gamma":0.99,
30+
"num_workers":3,
31+
"td_lambda":0.5,
32+
"print_training":false,
33+
"print_model_call_times":false,
34+
"print_mode":"terminal",
35+
"update_gradients_every":8,
36+
"worker_wait":0.01,
37+
"profile":false,
38+
"normalization_style":"layer",
39+
"main_worker_use_epsilon":false,
40+
"e_greedy_min":0.01,
41+
"e_greedy_max":0.04,
42+
"entropy_loss_scaling":0.05,
43+
"normalize_entropy_loss":true,
44+
"normalize_pi_loss":true,
45+
"aux_tasks_weight_scale":1.0,
46+
"teacher_start_evaluations_at_episode":500,
47+
"teacher_evaluation_steps":20,
48+
"teacher_promote_wins":0.9,
49+
"teacher_demote_wins":0.65
5750
}
-3.29 MB
Binary file not shown.
-6.48 MB
Binary file not shown.
801 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
22
set -e
3-
. .env/bin/activate
3+
. ../../.env/bin/activate
44
echo "Build python package..."
55
python setup.py sdist bdist_wheel

0 commit comments

Comments
 (0)