没有合适的资源?快使用搜索试试~ 我知道了~
首页Chemistry.AI | 基于卷积神经网络(CNN)预测分子特性
Chemistry.AI | 基于卷积神经网络(CNN)预测分子特性
25 下载量 109 浏览量
更新于2023-03-03
评论 1
收藏 55KB PDF 举报
CNN :Convolutional Neural Networks (卷积神经网络 ) 环境准备 Python版本:Python 3.6.8 PyTorch版本:PyTorch1.1.0 RDKit版本:RDKit 2020.03.1 基于卷积神经网络(CNN)预测分子特性 导入库 from rdkit import Chem from rdkit.Chem.Crippen import MolLogP import numpy as np import torch import time 载入数据 maxlen = 64 with open('smiles.txt') as f:
资源详情
资源评论
资源推荐
Chemistry.AI | 基于卷积神经网络(基于卷积神经网络(CNN)预测分子特性)预测分子特性
CNN :Convolutional Neural Networks (卷积神经网络 )
环境准备环境准备
Python版本:Python 3.6.8
PyTorch版本:PyTorch1.1.0
RDKit版本:RDKit 2020.03.1
基于卷积神经网络(基于卷积神经网络(CNN)预测分子特性)预测分子特性
导入库
from rdkit import Chem
from rdkit.Chem.Crippen import MolLogP
import numpy as np
import torch
import time
载入数据
maxlen = 64
with open('smiles.txt') as f:
smiles = f.readlines()[:] smiles = [s.strip() for s in smiles] smiles = [s.split()[1] for s in smiles] smiles = [s for s in smiles if len(s)<maxlen]
#Characters of smiles
all_smiles=''
for s in smiles: all_smiles+=s
chars = sorted(list(set(list(all_smiles))))
chars.append('X')
c_to_i = {c:i for i,c in enumerate(chars)}
print ('Max len:', maxlen)
print ('Number of chars:', len(chars))
print (chars)
print (c_to_i)
Max len: 64
Number of chars: 46
['#', '(', ')', '+', '-', '.', '/', '1', '2', '3', '4', '5', '6', '7', '=', '@', 'B', 'C', 'F', 'G', 'H', 'I', 'K', 'L', 'M', 'N', 'O', 'P', 'S', 'V', 'Z', '[', '\', ']', 'a', 'c', 'e', 'g', 'i', 'l', 'n', 'o', 'r', 's', 'u', 'X']
{'#': 0, '(': 1, ')': 2, '+': 3, '-': 4, '.': 5, '/': 6, '1': 7, '2': 8, '3': 9, '4': 10, '5': 11, '6': 12, '7': 13, '=': 14, '@': 15, 'B': 16, 'C': 17, 'F': 18, 'G': 19, 'H': 20, 'I': 21, 'K': 22,
'L': 23, 'M': 24, 'N': 25, 'O': 26, 'P': 27, 'S': 28, 'V': 29, 'Z': 30, '[': 31, '\': 32, ']': 33, 'a': 34, 'c': 35, 'e': 36, 'g': 37, 'i': 38, 'l': 39, 'n': 40, 'o': 41, 'r': 42, 's': 43, 'u':
44, 'X': 45}
计算每个分子的分子指纹和LogP
Y = [] num_data = 20000
st = time.time()
for s in smiles[:num_data]:
m = Chem.MolFromSmiles(s)
logp = MolLogP(m)
Y.append(logp)
end = time.time()
print (f'Time:{(end-st):.3f}')
数据批处理
from torch.utils.data import Dataset, DataLoader
class MolDataset(Dataset):
def __init__(self, smiles, properties, c_to_i, maxlen):
self.c_to_i = c_to_i
self.maxlen = maxlen
self.smiles = smiles
self.properties = properties
def __len__(self):
return len(self.smiles)
def __getitem__(self, idx):
weixin_38509082
- 粉丝: 3
- 资源: 965
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- RTL8188FU-Linux-v5.7.4.2-36687.20200602.tar(20765).gz
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
- SPC统计方法基础知识.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0