Conversation
…e et al. TDR), and some quality of life and infrastructure features (environment.yml, etc.)
recreation of CTRNN of mante (2013) nature paper based on description in supplementary info
PID preliminary analysis on sinusoid-trained RNN
… on both neurogym tasks
…ic generation), Perceptual and Context now generated from ContextDecisionMaking-v0
…n and do pid analysis
There was a problem hiding this comment.
Pull request overview
This PR adds a CTRNN size-comparison training + Gaussian PID analysis pipeline, along with a NeuroGym-based Mante (2013)-style dataset generator/loader, and supporting analysis/notebook utilities to reproduce and visualize results.
Changes:
- Added Mante-style dataset generation + PyTorch loading utilities for NeuroGym tasks (context vs perceptual modes).
- Added CTRNN model + loss utilities and expanded Gaussian PID analysis scripts/figures.
- Added end-to-end size-comparison scripts, packaging/environment files, and roadmap automation docs/scripts.
Reviewed changes
Copilot reviewed 20 out of 127 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| src/training/loss.py | Adds condition-dependent loss (vanilla/efficient/predictive). |
| src/training/.gitkeep | Keeps training package directory in git. |
| src/tasks/README_data.md | Documents Mante-style dataset pipeline and usage. |
| src/tasks/neurogym_wrapper.py | Adds config-driven NeuroGym dataset/trial helpers. |
| src/tasks/mante_config.py | Adds Mante-style timings/coherence configuration. |
| src/tasks/data_loader.py | Adds NPZ loader with optional temporal subsampling and channel selection. |
| src/tasks/data_generator.py | Adds NPZ dataset generator for context vs masked perceptual variants. |
| src/models/ctrnn.py | Adds CTRNN module with predictive head and optional dynamics return. |
| src/models/.gitkeep | Keeps models package directory in git. |
| src/analysis/RNN.py | Adds simple Elman RNN helper used in analysis code. |
| src/analysis/PID_figures.py | Adds plotting script for PID bar figures. |
| src/analysis/main.py | Adds a training + evaluation script for a sinusoid toy system. |
| src/analysis/gaussian_pid.py | Adds analytic Gaussian MMI-PID implementation + RNN wrapper. |
| src/analysis/compute_pid_sinusoid.py | Adds a script to compute PID on sinusoid-trained RNN ensembles. |
| size_comparison/data_loading_ver/ctrnn_pid_both_tasks.py | Adds CTRNN training + PID analysis across PDM/CDM with NPZ fallback. |
| size_comparison/CDM/results/ctrnn_pid_sweep_cdm.py | Adds CTRNN PID sweep script over multiple hidden sizes for CDM. |
| results/pid_outputs/.gitkeep | Keeps PID outputs directory in git. |
| results/model_weights/.gitkeep | Keeps model weights directory in git. |
| results/model_activations/.gitkeep | Keeps activations directory in git. |
| requirements.txt | Updates pinned Python dependencies (torch/numpy/scipy/etc). |
| README.md | Updates repository structure documentation and trims team section. |
| pyproject.toml | Adds basic packaging metadata and dependencies. |
| notebooks/roadmap_generator/setup_roadmap.py | Adds GitHub Project roadmap provisioning script. |
| notebooks/roadmap_generator/SETUP_INSTRUCTIONS.md | Adds manual setup instructions for the roadmap generator. |
| notebooks/Jan_example_rnn/true_rnn/y_VanDerPol.pt | Adds example data artifact for true_rnn notebook flow. |
| notebooks/Jan_example_rnn/true_rnn/y_Lorenz.pt | Adds example data artifact for true_rnn notebook flow. |
| notebooks/Jan_example_rnn/true_rnn/utils.py | Adds spectrum utilities for notebook experiments. |
| notebooks/Jan_example_rnn/true_rnn/trueRNN.py | Adds TrueRNN notebook model implementation. |
| notebooks/Jan_example_rnn/true_rnn/main.py | Updates notebook script entrypoint/imports/paths. |
| notebooks/Jan_example_rnn/true_rnn/init.py | Marks true_rnn as a package. |
| notebooks/Jan_example_rnn/dyn_rnn/y_VanDerPol.pt | Adds example data artifact for dyn_rnn notebook flow. |
| notebooks/Jan_example_rnn/dyn_rnn/y_Lorenz.pt | Adds example data artifact for dyn_rnn notebook flow. |
| notebooks/Jan_example_rnn/dyn_rnn/utils.py | Adds spectrum utilities for notebook experiments. |
| notebooks/Jan_example_rnn/dyn_rnn/main.py | Updates notebook script entrypoint/imports/paths and hyperparams. |
| notebooks/Jan_example_rnn/dyn_rnn/dynRNN.py | Adds DynRNN notebook model implementation. |
| notebooks/Jan_example_rnn/dyn_rnn/init.py | Marks dyn_rnn as a package. |
| notebooks/Jan_example_rnn/init.py | Marks Jan_example_rnn as a package. |
| figures/.gitkeep | Keeps figures directory in git. |
| environment.yml | Adds a conda environment definition (PyTorch CUDA 12.1 + deps). |
| .gitignore | Updates ignore rules for generated data and weights. |
Comments suppressed due to low confidence (2)
notebooks/Jan_example_rnn/true_rnn/main.py:8
- The import path and data directory are inconsistent with the actual folder name (
notebooks/Jan_example_rnn/...). As written, this script will fail to importTrueRNNand will look for data under a non-existentexample_rnn/directory.
notebooks/Jan_example_rnn/dyn_rnn/main.py:8 - The import path and data directory are inconsistent with the actual folder name (
notebooks/Jan_example_rnn/...). As written, this script will fail to importDynRNNand will look for data under a non-existentexample_rnn/directory.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+12
to
+33
| # 1. Vanilla Supervised (Cross Entropy on the last timestep for PoC) | ||
| # Note: In real NeuroGym tasks, you mask this to the decision period. | ||
| ce_loss = F.cross_entropy(outputs[:, -1, :], targets) | ||
|
|
||
| total_loss = ce_loss | ||
|
|
||
| # 2. Activity-regularized (Efficient Coding) | ||
| if condition == "efficient": | ||
| # lambda * mean(h^2) across all timesteps and batches | ||
| activity_penalty = lambda_reg * torch.mean(hidden_states ** 2) | ||
| total_loss += activity_penalty | ||
|
|
||
| # 3. Predictive auxiliary (Predictive Coding) | ||
| elif condition == "predictive": | ||
| # mu * MSE(pred(t), u(t+1)) | ||
| # We predict the input at the next timestep. | ||
| # Exclude the last prediction since there is no t+1 input to compare it to. | ||
| pred_t = predictions[:, :-1, :] | ||
| actual_next_u = inputs[:, 1:, :] | ||
|
|
||
| predictive_loss = mu_reg * F.mse_loss(pred_t, actual_next_u) | ||
| total_loss += predictive_loss |
Comment on lines
+30
to
+34
| if isinstance(config, str): | ||
| config = {"task": config} | ||
|
|
||
| task_name = config.get("task_name", "ContextDecisionMaking-v0") | ||
| batch_size = config.get("batch_size", 64) |
Comment on lines
+59
to
+60
| env.reset(seed=42) | ||
|
|
Comment on lines
+42
to
+44
| # FIX: correct coherence handling | ||
| cohs = config.get("coh_levels", None) | ||
|
|
Comment on lines
+100
to
+103
| env.reset() | ||
|
|
||
| ob_dict = OB_DICTS[task_name] | ||
|
|
Comment on lines
+55
to
+56
| # Total trial duration = 750ms at dt=1ms means exactly 750 timesteps. | ||
| TIMING = { |
Comment on lines
+12
to
+15
| from typing import Dict | ||
|
|
||
| from mante_config import CONFIG, UNIFORM_COHS, MANTE_TEST_COHS | ||
|
|
Comment on lines
+83
to
+86
| RESULTS_DIR = Path(r"E:\TUM\3sem\NeuroAI\project\github_neuroai\results") | ||
|
|
||
| WEIGHTS_DIR = RESULTS_DIR / 'weights' | ||
| WEIGHTS_DIR.mkdir(parents=True, exist_ok=True) |
Comment on lines
+958
to
+973
| for h in args.hidden_sizes: | ||
| print(f"\n{'#'*60}") | ||
| print(f" HIDDEN SIZE = {h}") | ||
| print(f"{'#'*60}") | ||
|
|
||
| main( | ||
| hidden_size = h, | ||
| pdm_dir = args.pdm_dir, | ||
| cdm_dir = args.cdm_dir, | ||
| num_epochs = args.num_epochs, | ||
| patience = args.patience, | ||
| lr = args.lr, | ||
| batch_size = args.batch_size, | ||
| n_test_trials = args.n_test_trials, | ||
| n_bipartitions = args.n_bipartitions, | ||
| ) No newline at end of file |
Comment on lines
+10
to
+17
| dependencies = [ | ||
| "torch==2.4.1+cu121", | ||
| "numpy", | ||
| "scipy", | ||
| "matplotlib", | ||
| "seaborn", | ||
| "neurogym==2.3.1" | ||
| ] |
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.