Repository navigation
Adaptation demo - #7
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an “on-device adaptation” demo suite (MNIST + rat nerve signatures) around ESCAPE‑NET Mini, including host-side streaming tools, offline/figure scripts, and weight export utilities; also adds two external-repo code summaries and removes generated graphify outputs.
Changes:
- Introduces a complete adaptation demo package under
scripts/FREDERIK MNIST/adaptation/(pretraining, interactive live drift demos, and intervention figure generators for MNIST and rat signatures). - Adds additional MNIST adaptation comparison/demo scripts (
adapt_demo*.py,adapt_compare*.py). - Adds documentation summaries (
docs/*Repo_Code_Summary.md) and removesgraphify-out/*generated artifacts.
Reviewed changes
Copilot reviewed 50 out of 98 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/FREDERIK MNIST/adaptation/README.md | Documents the new adaptation demo layout, model, datasets, and wire protocol. |
| scripts/FREDERIK MNIST/adaptation/rat/rat_interventions.py | Generates the rat intervention figure comparing frozen vs adapting under shifts. |
| scripts/FREDERIK MNIST/adaptation/rat/pretrain_signatures.py | Pretrains the 3-class rat model and exports Arduino header + normalization stats. |
| scripts/FREDERIK MNIST/adaptation/rat/adapt_live_rat.py | Interactive host streamer/visualizer for on-device adaptation on rat signatures. |
| scripts/FREDERIK MNIST/adaptation/mnist/pretrain_escapenet.py | Trains MNIST ESCAPE‑NET Mini and exports pretrained weights header. |
| scripts/FREDERIK MNIST/adaptation/mnist/mnist_interventions.py | Produces MNIST intervention figure simulating on-device SGD adaptation. |
| scripts/FREDERIK MNIST/adaptation/mnist/adapt_live.py | Interactive host streamer/visualizer for on-device MNIST adaptation. |
| scripts/FREDERIK MNIST/adaptation/.gitignore | Ignores large rat signature datasets, generated figures, and Python caches. |
| scripts/FREDERIK MNIST/adapt_demo.py | Serial-driven 5-phase MNIST inversion adaptation demo (board-in-the-loop). |
| scripts/FREDERIK MNIST/adapt_demo_host.py | PC-only dry run of the 5-phase MNIST inversion adaptation demo. |
| scripts/FREDERIK MNIST/adapt_compare.py | Plots full online timeline for warm vs cold start under inversion shift. |
| scripts/FREDERIK MNIST/adapt_compare_v1.py | Alternate comparison script for warm vs cold start adaptation timeline. |
| scripts/FREDERIK CAP DETECTION/_test_bigcnn_all.py | Adds a per-rat “big CNN” throwaway evaluation script for signatures. |
| jupiter_notebooks/save_spatial_emphasis.py | Adds a notebook-adjacent helper file (currently only planning comments). |
| jupiter_notebooks/extract_cap_v2_images.py | Utility to extract embedded PNG outputs from a v2 preprocessing notebook. |
| jupiter_notebooks/extract_cap_images.py | Utility to extract embedded PNG outputs from the preprocessing notebook. |
| jupiter_notebooks/Check_data_signatures.ipynb | Updates notebook metadata (kernel display name / Python version). |
| graphify-out/GRAPH_REPORT.md | Removes generated graph report markdown. |
| graphify-out/cache/f3be4a202b6e2f9175bf6b0916f416f7c74656741af3f561c5b56ba5dfb7d92d.json | Removes generated graph cache artifact. |
| graphify-out/cache/e2ed78b7d0cc40c28ad9d6245e845f99b27664b920d087cf1edc999b29fd2d25.json | Removes generated graph cache artifact. |
| graphify-out/cache/dadc77096afdf32749edb9b03ae2816b47e45bcebd1dd726919754ad94e7021d.json | Removes generated graph cache artifact. |
| graphify-out/cache/d121a3c5f79a0916fa97d6ef6182c01813b0a57731149ebf8e21dbe205f334d7.json | Removes generated graph cache artifact. |
| graphify-out/cache/c9e80bcfe7ca42718a8abcca38485c048e5ee614954863cb293bc076320f0c90.json | Removes generated graph cache artifact. |
| graphify-out/cache/c8d830d0e6684f80dbe08ffdb2656b6edee564b73646d8158971b630519dfc12.json | Removes generated graph cache artifact. |
| graphify-out/cache/c0cae676bc92e50f18af9155b0ed5042296ddcc5b9ad1adfd0d2a8515dd8f0ee.json | Removes generated graph cache artifact. |
| graphify-out/cache/98f3a2843c3cd1e2161c2d3ae2927ed87dc0f15ddcda96b4ae64e279dbd98f22.json | Removes generated graph cache artifact. |
| graphify-out/cache/964536e687d39a7ba9e50a9498dd17a93d83caddc3e0ee10e13f137d28e544af.json | Removes generated graph cache artifact. |
| graphify-out/cache/95ea2400302940e5b64120010387cf9732fc5243760ff890c8d2fa7eac74bd21.json | Removes generated graph cache artifact. |
| graphify-out/cache/7b2386f13fe358cb2116e3dcbad6e357cd2d275df5449ac62f8bea0ec0464044.json | Removes generated graph cache artifact. |
| graphify-out/cache/65eb658e0a2166e593a1cbdf203447b982b7d3adfe92074a7e6eb751ac9aa386.json | Removes generated graph cache artifact. |
| graphify-out/cache/5c267d71041c56213dfcf2f8a0b81c394dcdeee4ef31196ef334ab2736370880.json | Removes generated graph cache artifact. |
| graphify-out/cache/48dd67e549ffbc7f2b5a56453ae7a86cc0a7552e4e30081fcc3696ed223e1ece.json | Removes generated graph cache artifact. |
| graphify-out/cache/47a79cae590253fe439408d62a853ad436f6c11714980e2784149184d7a91287.json | Removes generated graph cache artifact. |
| graphify-out/cache/445172fc94e1faaf5e44438de8c19cc36e4758822b463aba21b242d83f8f036a.json | Removes generated graph cache artifact. |
| graphify-out/cache/18308a56d5bca75647a42d4e17b74c6542d951c1116f21da68bfe20c94b4babe.json | Removes generated graph cache artifact. |
| graphify-out/cache/12ba9427d0e8537496b4c7bf795e6352630d3b402b7a8e59b29fb7da911d9f17.json | Removes generated graph cache artifact. |
| docs/TBME_2023_Repo_Code_Summary.md | Adds a focused summary of relevant code/labeling insights from TBME repo. |
| docs/pyeCAP_Repo_Code_Summary.md | Adds a focused summary of pyeCAP’s relevance/transferable concepts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+60
to
+61
| def load_pretrained(): | ||
| h = open(HERE / "AdaptationDemo" / "pretrained_weights.h").read() |
Comment on lines
+56
to
+58
| def load(rat): | ||
| d = np.load(HERE / "data" / f"signatures_signed_rat{rat}.npz") | ||
| return d["signatures"], d["labels"].astype(np.int64), d["groups"] |
Comment on lines
+100
to
+103
| def load_rat(r): | ||
| d = np.load(HERE / "data" / f"signatures_signed_rat{r}.npz") | ||
| return d["signatures"], d["labels"].astype(np.int64) | ||
|
|
Comment on lines
+240
to
+243
| if f.exists(): | ||
| d = np.load(f) | ||
| data[r] = (d["signatures"], d["labels"].astype(np.int64)) | ||
| print(f" RAT{r}: {len(d['labels'])} signatures") |
Comment on lines
+264
to
+265
| norm = np.load(HERE / "data" / "norm.npz") | ||
| mean, std = float(norm["mean"]), float(norm["std"]) |
Comment on lines
+347
to
+349
| if __name__ == "__main__": | ||
| mp.set_start_method("spawn") | ||
| main() |
Comment on lines
+125
to
+126
| vmax = np.abs(sample).max() + 1e-6 | ||
| ax0 = fig.add_subplot(gs[row, 0]); ax0.imshow(X4[0], aspect="auto", cmap="RdBu_r", vmin=-vmax, vmax=vmax) |
Comment on lines
+1
to
+5
| # The user wants "this image" (Spatial Emphasis Representation) saved to "the folder". | ||
| # The simplest approach is to extract from the images we just dumped, maybe one of them is the right one, | ||
| # or I can just run the user's notebook code that generates it and save as "spatial_emphasis.png" | ||
|
|
||
| # I don't need to rebuild it if I can figure out which image it is. But the user just asked "save this image to the folder", and attached an image file 'file.png' which was already available locally. |
Comment on lines
+140
to
+141
| roll_warm = rolling(full_warm[~np.isnan(full_warm[:ROLL_WINDOW + PRE_SHIFT_N]) | ||
| if False else slice(None)], ROLL_WINDOW) |
Comment on lines
+1
to
+2
| """Throwaway: big (numpy) ESCAPE-NET per rat, faithful signature_extraction | ||
| output, 3-class. Prints a per-rat accuracy summary. Not committed.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.