Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
yult0821 7b20e85d25 | 1 year ago | |
---|---|---|
hybrid_snn_conversion | 2 years ago | |
pics | 1 year ago | |
README.md | 1 year ago | |
__init__.py | 2 years ago | |
run_eg.log | 2 years ago | |
snn4imagenet_test.sh | 1 year ago | |
testSNN_script_user.py | 1 year ago | |
utils.py | 2 years ago |
dockerhub.pcl.ac.cn:5000/user-images/openi:hybrid-snn-conversion1
Brain & Deep-learning Interdisciplinary Platform (BDIP)组织管理并开放了一个“大规模类脑计算研究平台”,该平台依托openI启智社区进行建设,拥有丰富的神经数据、深度学习模型以及模型评测、可视化技术,帮助脑科学研究者运用深度学习技术,为人工智能研究者提供神经数据,推动脑科学与人工智能交叉研究,促进类脑智能研究。欢迎感兴趣的小伙伴前往访问使用,同时也非常欢迎加入我们成为贡献者!
本仓库为snn4imagenet打榜任务提供样例。为了解最新榜单,请参见网页Snn4ImageNet榜单。
如果您想要参与snn4imagenet打榜任务,请按照下述说明进行操作。
1、注册成为openI启智社区用户,加入组织Brain & Deep-learning Interdisciplinary Platform (BDIP),成为贡献者。
2、准备好预训练模型:模型基于PyTorch
,输入图片尺寸为224x224x3,输出为经由softmax
函数处理得到的一维概率向量 (1000类)。
3、创建项目仓库,上传SNN相关代码和预训练模型。其中,预训练模型可以在对应仓库以数据集的形式上传,模型文件可命名为model.pth
(需压缩为zip文件进行上传,zip文件可根据模型特点或版本由用户任意命名)。此外,预训练模型也能够通过仓库模型
栏目上传,启动任务时可通过模型
选项进行选择,启动任务后存储于/pretrainmodel/xxx.pth
(建议首选此类新方式,方便在评测任务
中使用)。启动云脑任务DEBUG
模式,搭建镜像,调试代码,使其可运行成功。请注意单次DEBUG任务最长可持续4小时。调试成功后需要在仓库“云脑”栏目对应任务条目下停止任务
前选择提交镜像
,自行命名,以备后续使用(例如,当前仓库运行使用的镜像为dockerhub.pcl.ac.cn:5000/user-images/openi:hybrid-snn-conversion1
,可用做基础镜像)。此外,镜像中应安装requests, json, argparse, datetime, sys, os
等基础Python包。
启动DEBUG
任务后,仓库代码可见于/code/
路径下,其中示例测试脚本为testSNN_script_user.py
,用户可在正式评测之前通过该示例脚本进行调试,以确保评测任务能正常运行。在任务启动时数据集/模型
可选择预训练模型,如此启动任务后预训练模型可见于/dataset/
路径下(例如,当前仓库运行使用的数据集为pretrained_model.zip
,则预训练模型存储于/dataset/pretrained_model/model.pth
),或者/pretrainmodel/xxx.pth
。
评测过程需要用户准备一个utils.py
文件,其中定义一个load_MyModel()
函数和一个eval_one_batch()
函数。该文件主要涵盖如下功能:模型初始化、导入预训练模型、导入模型推断过程所需的模块及函数、对单个batch做推断。load_MyModel()
函数返回值为一个tuple
,其中第一个元素为可直接用于推断过程的模型,后续元素为推断过程(即forward过程
)所需的参数(请注意按顺序排列)。eval_one_batch()
函数负责接收模型(及参数)和输入,输出分类概率。详情请参见该仓库中的示例文件utils.py
。评测结果包括分类准确率ACC@1、ACC@5,以及测试耗时。
4、正式进行模型评测:启动云脑评测任务
,选择模型评测
,并填入相应信息。任务名称
填写模型名称,例如hybrid_snn_conversion
(同一仓库下不可存在重复的任务名称
,若要重复使用同一个任务名称
,需先行删除之前的任务记录);任务描述
填写模型简介;评测类型
选择snn4imagenet
;镜像
选择前述自行搭建的镜像;模型
选择预训练模型对应的文件。填写信息完成之后,点击新建任务
即可开始模型评测任务。在openI云脑测试任务中,社区提供1个GPU (V100)和4个CPU的计算资源。当前测试脚本选用GPU作为torch.device
。任务结束后,评测脚本会将任务相关信息、模型相关信息、及测试结果写入后端数据库,并据此更新榜单页面。随后,用户可以通过云脑
栏目下对应任务条目的评测类型
按钮(即snn4imagenet
)查看最新的榜单页面。
5、下述两段代码分别展示了调试所需的shell脚本snn4imagenet_test.sh
,以及示例测试脚本testSNN_script_user.py
中接收模型及模型推断
对应的重要代码。
#!/bin/bash
# self debugging
/opt/conda/bin/python /code/testSNN_script_user.py --modelname 'hybrid_snn_conversion' --modelpath '/dataset/pretrained_model/model.pth' --modeldescription 'A convert-then-finetune snn model proposed in Rathi et al. ICLR 2020 (Enabling Deep Spiking Neural Networks with Hybrid Conversion and Spike Timing Dependent Backpropagation)'
# --modelpath '/pretrainmodel/xxx.pth'
sys.path.append("/code/")
import utils
model_pars = utils.load_MyModel()
model = model_pars[0]
if len(model_pars) > 1:
forward_pars = model_pars[1:]
...
...
if len(model_pars) == 1:
output = utils.eval_one_batch(model, data)
elif len(model_pars) > 1:
output = utils.eval_one_batch(model, data, *forward_pars)
图1:预训练模型以数据集形式上传。
snn4imagenet
Jupyter Notebook Python Shell Text
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》