Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
yult0821 a965f4d0ff | 1 year ago | |
---|---|---|
model_checkpoint | 1 year ago | |
pics | 1 year ago | |
.gitignore | 1 year ago | |
README.md | 1 year ago | |
activation.py | 1 year ago | |
benchmark.py | 1 year ago | |
custom_model.py | 1 year ago | |
dataset.py | 1 year ago | |
metric.py | 1 year ago | |
score_a_model_user.py | 1 year ago | |
sim2brain_snn.sh | 1 year ago | |
visualmodel.py | 1 year ago |
Applying SNNs to model biological visual cortices and using RSA (representation similarity analysis) method to evaluate the neural similarity
【基础镜像】dockerhub.pcl.ac.cn:5000/user-images/openi:spikingjelly
Brain & Deep-learning Interdisciplinary Platform (BDIP)组织管理并开放了一个“大规模类脑计算研究平台”,该平台依托openI启智社区进行建设,拥有丰富的神经数据、深度学习模型以及模型评测、可视化技术,帮助脑科学研究者运用深度学习技术,为人工智能研究者提供神经数据,推动脑科学与人工智能交叉研究,促进类脑智能研究。欢迎感兴趣的小伙伴前往访问使用,同时也非常欢迎加入我们成为贡献者!
本仓库为similarity2brain_snn打榜任务提供基础代码库、基础镜像及测试样例。为了解最新榜单,请参见网页SNN脑相似性榜单。
如果您想要参与similarity2brain_snn打榜任务,请按照下述说明进行操作。
1、注册成为openI启智社区用户,加入组织Brain & Deep-learning Interdisciplinary Platform (BDIP),成为贡献者。
2、准备好预训练模型:模型基于SpikingJelly
,输入图片尺寸为224x224x3。
3、本仓库运行所需的镜像dockerhub.pcl.ac.cn:5000/user-images/openi:spikingjelly
已安装好相关依赖包,可以作为新建仓库的基础镜像。所需数据集已上传至openI启智社区,包含本仓库运行所需的相关数据,可在启动云脑任务时通过数据集
选项进行选择sim2brian_snn_data.zip
。此打榜任务采用的数据集为艾伦脑研究所小鼠视觉编码数据集,包含小鼠观察视觉刺激(自然场景图片)时通过Neuropixels电极同步记录的小鼠视觉皮层六个脑区的高时间分辨率脉冲信号。实验中,共118张自然场景图片以随机的方式呈现给小鼠,每张图片持续250ms;重复该刺激施加的方案共50次,构成整个视觉刺激合集,相应的小鼠视觉皮层六个脑区的脉冲响应(时序信号)则作为分析用的神经信号。
4、在本示例仓库基础上新建项目仓库,上传SNN相关代码和预训练模型。首先需更新、替换custom_model.py
,该文件负责模型自定义、模型导入,并需指定待进行神经相似性评测的模型层。预训练模型可以存储于项目仓库中,类似于本示例中的model_checkpoint/sew_resnet18.pth
。另外,预训练模型也能够通过仓库模型
栏目上传,启动任务时可通过模型
选项进行选择,启动任务后存储于/pretrainmodel/xxx.pth
路径。通过仓库云脑
栏目启动云脑任务DEBUG
模式,选择上述镜像,并根据模型执行需求安装环境,搭建新镜像,调试代码,使其可运行成功。请注意单次DEBUG任务最长可持续4小时。调试成功后需要在仓库云脑
栏目对应任务条目下停止
任务前选择提交镜像
,自行命名,以备后续使用。请注意,镜像中应安装requests, json, argparse, datetime, sys, os
等基础Python包。
启动DEBUG
任务后,仓库代码可见于/code/
路径下,其中示例测试脚本为score_a_model_user.py
,用户可在正式评测之前通过该示例脚本进行调试,以确保评测任务能正常运行。如果预训练模型通过模型
栏目上传,那么在任务启动时可通过模型
选项可选择预训练模型,如此启动任务后预训练模型可见于/pretrainmodel/xxx.pth
路径。
评测过程需要用户准备一个custom_model.py
文件。该文件主要涵盖如下功能:模型定义、模型初始化、模型实例化(导入预训练模型及初始化)、定义待评测的模型层等。详情请参见该仓库中的示例文件custom_model.py
,用户在实际应用中需对该文件进行更新替换。评测结果包括各脑区的神经相似性得分、跨脑区平均得分,以及测试耗时。
5、正式进行模型评测:启动云脑评测任务
,选择模型评测
,并填入相应信息。任务名称
填写模型名称,例如sew_resnet18
,注意与custom_model.py
中实例化的模型名称保持一致(同一仓库下不可存在重复的任务名称
,若要重复使用同一个任务名称
,需先行删除之前的任务记录);任务描述
填写模型简介;评测类型
选择sim2brain_snn
;数据集
从下拉框选择(AllenMouse\MacaqueSynthetic\MacaqueFace
,目前仅能选择AllenMouse
方法);镜像
选择前述自行搭建的镜像;模型
选择预训练模型。填写信息完成之后,点击新建任务
即可开始模型评测任务。在openI云脑测试任务中,社区提供1个GPU (V100)和4个CPU的计算资源。任务结束后,评测脚本会将任务相关信息、模型相关信息、及测试结果写入后端数据库,并据此更新榜单页面。随后,用户可以通过云脑
栏目下对应任务条目的评测类型
按钮(即sim2brain_snn
)查看最新的榜单页面。
6、下述两段代码分别展示了测试所需的shell脚本sim2brain_snn.sh
和测试脚本score_a_model_user.py
中的重要代码片段。
#!/bin/bash
cd /code/
# self debugging
/opt/conda/bin/python /code/score_a_model_user.py --benchmark 'AllenMouse' --dataset-path '/dataset/' --metric 'RSA' --model-name 'sew_resnet18' --model-checkpoint 'model_checkpoint/sew_resnet18.pth' --model-description 'SEW-ResNet18 trained on ImageNet'
# /pretrainmodel/xxx.pth
print("Loading model and chosen layers")
import custom_model
model, model_path = custom_model.get_model(args.model_name, args.model_checkpoint)
layers = custom_model.get_layers()
print(f"The model to be tested: {args.model_name}\n{model}")
print(f"The layers to be analyzed: \n{layers}")
图1:数据集信息。
Applying SNN to evaluate neural similarity
Python Shell
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》