Official Implementation of Human-like Cognitive Generalization for Large Models via Mental Representation-Guided Supervision in PyTorch
Python
7
2 commits
updated Aug 14, 2026
Official Implementation in PyTorch
2025-05-14: Preprint release.
2026-04-01: Published in Nature Communications.
Create a conda environment and install the packages necessary to run the code.
conda create -n brainintheloop python=3.8.13 -y
conda activate brainintheloop
pip install -r requirements.txt
Fig*.ipynb: Jupyter notebooks for reproducing the paper figures from source data
β£ π dataset
β β£ π fMRI
β β β£ π DeepImageReconstruction
β β β β sub-01_perceptionNaturalImageTraining_VC_v2.h5
β β β β sub-02_perceptionNaturalImageTraining_VC_v2.h5
β β β β sub-03_perceptionNaturalImageTraining_VC_v2.h5
β β β β sub-01_perceptionNaturalImageTest_VC_v2.h5
β β β β sub-02_perceptionNaturalImageTest_VC_v2.h5
β β β β sub-03_perceptionNaturalImageTest_VC_v2.h5
python download.py --save_path ./dataset/. Please decompress them and put them in this repository as shown below.β£ π dataset
β β£ π ImageNet
β β β£ π n01443537
β β β β n01443537_2.JPEG
β β β β ...
β β β£ π n01518878
β β β β n01518878_2.JPEG
β β β β ...
β β β£ π ...
β£ π dataset
β β£ π DIR
β β β£ π stimulus
β β β π train
β β β β β *.JPEG
β β β β β ...
β β β π test
β β β β β *.JPEG
β β β β β ...
(Optional) Download THINGS-odd-one-out and THINGS object concept and object image database
(Optional) Download DINOv2-small, DINOv2-base, DINOv2-large, SimCLR-small, SimCLR-base, and SimCLR-large.
CLIP
python extract_clip_features.py --model_size ViT-B/16 --extract_THINGS False
--model_size can be either ViT-B/16 or ViT-L/14.
SimCLR
python extract_simclr_features.py --model_size simclr_base_25ep --extract_THINGS False
--model_size can be simclr_small_25ep, simclr_base_25ep, or simclr_large_25ep.
DINOv2
python extract_dinov2_features.py --model_size dinov2-base --extract_THINGS False
--model_size can be dinov2-small, dinov2-base, or dinov2-large.
python brain_in_the_loop_training.py --proxy CLIP --model_size base --sub sub-3
dataset: Folder to dataset filespretrained_features: Folder to pretrained feature filespretrained_models: Folder to pretrained model filesdata, modules: Brain-in-the-loop supervision codessmallcap: SMALLCAP codesdownload.py: Codes for ImageNet downloadextract_*_features.py: Codes for extracting featuresbrain_in_the_loop_training.py: Codes for training brain-in-the-loop supervised modelsgpt_decoder_training.py: Codes for training gpt-based semantic reconstruction models@article{chen2026human,
title={Human-like Cognitive Generalization for Large Models via Mental Representation-Guided Supervision},
author={Chen, Jiaxuan and Qi, Yu and Wang, Yueming and Pan, Gang},
journal={Nature Communications},
year={2026},
publisher={Nature Publishing Group UK London}
}
We thank Kamitani Lab for making their raw and pre-processed data public. Our semantic reconstruction model implementation is based on the SMALLCAP. We thank these authors for making their codes available!
Official Implementation of Human-like Cognitive Generalization for Large Models via Mental Representation-Guided Supervision in PyTorch
Python
7
2 commits
updated Aug 14, 2026
Official Implementation in PyTorch
2025-05-14: Preprint release.
2026-04-01: Published in Nature Communications.
Create a conda environment and install the packages necessary to run the code.
conda create -n brainintheloop python=3.8.13 -y
conda activate brainintheloop
pip install -r requirements.txt
Fig*.ipynb: Jupyter notebooks for reproducing the paper figures from source data
β£ π dataset
β β£ π fMRI
β β β£ π DeepImageReconstruction
β β β β sub-01_perceptionNaturalImageTraining_VC_v2.h5
β β β β sub-02_perceptionNaturalImageTraining_VC_v2.h5
β β β β sub-03_perceptionNaturalImageTraining_VC_v2.h5
β β β β sub-01_perceptionNaturalImageTest_VC_v2.h5
β β β β sub-02_perceptionNaturalImageTest_VC_v2.h5
β β β β sub-03_perceptionNaturalImageTest_VC_v2.h5
python download.py --save_path ./dataset/. Please decompress them and put them in this repository as shown below.β£ π dataset
β β£ π ImageNet
β β β£ π n01443537
β β β β n01443537_2.JPEG
β β β β ...
β β β£ π n01518878
β β β β n01518878_2.JPEG
β β β β ...
β β β£ π ...
β£ π dataset
β β£ π DIR
β β β£ π stimulus
β β β π train
β β β β β *.JPEG
β β β β β ...
β β β π test
β β β β β *.JPEG
β β β β β ...
(Optional) Download THINGS-odd-one-out and THINGS object concept and object image database
(Optional) Download DINOv2-small, DINOv2-base, DINOv2-large, SimCLR-small, SimCLR-base, and SimCLR-large.
CLIP
python extract_clip_features.py --model_size ViT-B/16 --extract_THINGS False
--model_size can be either ViT-B/16 or ViT-L/14.
SimCLR
python extract_simclr_features.py --model_size simclr_base_25ep --extract_THINGS False
--model_size can be simclr_small_25ep, simclr_base_25ep, or simclr_large_25ep.
DINOv2
python extract_dinov2_features.py --model_size dinov2-base --extract_THINGS False
--model_size can be dinov2-small, dinov2-base, or dinov2-large.
python brain_in_the_loop_training.py --proxy CLIP --model_size base --sub sub-3
dataset: Folder to dataset filespretrained_features: Folder to pretrained feature filespretrained_models: Folder to pretrained model filesdata, modules: Brain-in-the-loop supervision codessmallcap: SMALLCAP codesdownload.py: Codes for ImageNet downloadextract_*_features.py: Codes for extracting featuresbrain_in_the_loop_training.py: Codes for training brain-in-the-loop supervised modelsgpt_decoder_training.py: Codes for training gpt-based semantic reconstruction models@article{chen2026human,
title={Human-like Cognitive Generalization for Large Models via Mental Representation-Guided Supervision},
author={Chen, Jiaxuan and Qi, Yu and Wang, Yueming and Pan, Gang},
journal={Nature Communications},
year={2026},
publisher={Nature Publishing Group UK London}
}
We thank Kamitani Lab for making their raw and pre-processed data public. Our semantic reconstruction model implementation is based on the SMALLCAP. We thank these authors for making their codes available!