模型名称: multimolecule/aparent2
模型链接: HuggingFace
模型描述: Aparent2 是一个基于扩张残差 1D CNN 的深度学习模型,用于预测核酸适配体(aptamer)与目标蛋白的结合亲和力。模型接受一段 DNA 序列(长度 205)作为输入,输出每个位置对 206 种标签的回归预测值。
模型架构: Dilated Residual 1D CNN(扩张残差一维卷积神经网络)
参数规模: 188,965
输入规格:
输出规格:
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch_npu | >= 2.1.0 | 昇腾 NPU 后端 |
| numpy | >= 1.26.0 | 数值计算 |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
安装命令:
pip install torch torch_npu numpy# 检查 NPU 设备
npu-smi info
# 验证 torch_npu
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"方式一:HuggingFace(推荐)
huggingface-cli download multimolecule/aparent2 --local-dir ./weights方式二:AtomGit 镜像(HuggingFace 下载慢时使用)
https://ai.gitcode.com/hf_mirrors/multimolecule/aparent2# 默认序列推理(使用内置 205bp 测试序列)
python3 inference.py --model-path ./weights
# 指定自定义 DNA 序列
python3 inference.py --model-path ./weights --sequence "ACGTACGT..."
# 指定库索引
python3 inference.py --model-path ./weights --library-index 11| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 目录路径(含 config.json 和 pytorch_model.bin) |
| --sequence | str | 内置默认序列 | DNA 序列字符串(A/C/G/T/N),长度 205 |
| --library-index | int | 11 | 文库索引,用于 bias 校正(0-12) |
| --batch-size | int | 1 | 推理批次大小 |
[信息] 权重加载成功: ./weights/pytorch_model.bin
[信息] 模型参数量: 188,965
[信息] 设备: npu
[信息] NPU型号: Ascend910_9362
[输入] 序列长度: 205
[输入] Library index: 11
[输出] Shape: (1, 206, 205)
[输出] dtype: float32
[输出] min: -61.387547, max: 4.134477, mean: -27.359608
[输出详情] Sample 0, 前10个位置的平均预测值:
pos 0: mean=-0.336543, min=-6.478485, max=4.134477
pos 1: mean=-5.485650, min=-11.627592, max=-1.014630
pos 2: mean=-15.060293, min=-21.202236, max=-10.589273
pos 3: mean=-14.141421, min=-20.283363, max=-9.670402
pos 4: mean=-14.966439, min=-21.108381, max=-10.495420
pos 5: mean=-17.486038, min=-23.627981, max=-13.015018
pos 6: mean=-21.807295, min=-27.949238, max=-17.336275
pos 7: mean=-18.953102, min=-25.095045, max=-14.482082
pos 8: mean=-15.722246, min=-21.864187, max=-11.251225
pos 9: mean=-19.851604, min=-25.993547, max=-15.380585
[状态] SUCCESS注意: 推理失败时必须输出
[状态] FAILED和错误信息,不得静默退出。
运行命令:
python3 inference.py --model-path ./weights输出:
[信息] 权重加载成功: ./weights/pytorch_model.bin
[信息] 模型参数量: 188,965
[信息] 设备: npu
[信息] NPU型号: Ascend910_9362
[输入] 序列长度: 205
[输入] Library index: 11
[输出] Shape: (1, 206, 205)
[输出] dtype: float32
[输出] min: -61.387547, max: 4.134477, mean: -27.359608
[输出详情] Sample 0, 前10个位置的平均预测值:
pos 0: mean=-0.336543, min=-6.478485, max=4.134477
pos 1: mean=-5.485650, min=-11.627592, max=-1.014630
pos 2: mean=-15.060293, min=-21.202236, max=-10.589273
pos 3: mean=-14.141421, min=-20.283363, max=-9.670402
pos 4: mean=-14.966439, min=-21.108381, max=-10.495420
pos 5: mean=-17.486038, min=-23.627981, max=-13.015018
pos 6: mean=-21.807295, min=-27.949238, max=-17.336275
pos 7: mean=-18.953102, min=-25.095045, max=-14.482082
pos 8: mean=-15.722246, min=-21.864187, max=-11.251225
pos 9: mean=-19.851604, min=-25.993547, max=-15.380585
[状态] SUCCESS运行命令:
python3 inference.py --model-path ./weights --sequence "ATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCG"输出:
[信息] 权重加载成功: ./weights/pytorch_model.bin
[信息] 模型参数量: 188,965
[信息] 设备: npu
[信息] NPU型号: Ascend910_9362
[输入] 序列长度: 205
[输入] Library index: 11
[输出] Shape: (1, 206, 205)
[输出] dtype: float32
[状态] SUCCESS


Aparent2 模型的评测使用回归任务标准指标:
评测指标:
| 指标 | 说明 |
|---|---|
| MSE (Mean Squared Error) | 均方误差,衡量预测值与真实值的偏离程度 |
| MAE (Mean Absolute Error) | 平均绝对误差,衡量预测精度 |
| Pearson Correlation | 皮尔逊相关系数,衡量预测值与真实值的线性相关性 |
评测命令:
# 使用真实数据集进行评测(需要提供包含序列和标签的 CSV/TSV 文件)
python3 -c "
import torch
from inference import Aparent2Model, seq_to_ids
import numpy as np
model = Aparent2Model()
state = torch.load('./weights/pytorch_model.bin', map_location='cpu')
model.load_state_dict(state, strict=False)
model.eval()
# 加载测试数据(序列和标签)
# sequences: list of 205-length DNA strings
# labels: numpy array of shape (N, 206, 205)
# 计算 MSE, MAE, Pearson correlation
"无