当前位置:网站首页>Torchdrug tutorial
Torchdrug tutorial
2022-07-04 18:53:00 【Stunned flounder (】
TorchDrug
Tensor based graph
Chart
The picture is TorchDrug The basic data structure used in . They can be regarded as graphic processing libraries in the tensor framework ( for example NetworkX) Generalization , At the same time enjoy GPU Acceleration and automatic differentiation .
import torchdrug as td
from torchdrug import data
edge_list = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]]
graph = data.Graph(edge_list, num_node=6)
graph.visualize()

molecular
A specific example of the graph in drug discovery is a molecule , It may have additional chemical constraints and characteristics . for example , We can SMILES String constructs a molecule .SMILES Is a language that uses linear strings to describe complex molecular structures .
mol = data.Molecule.from_smiles("C1=CC=CC=C1")
mol.visualize()
print(mol.node_feature.shape)
print(mol.edge_feature.shape)

Figure operation
A group of arbitrary graphs can also be processed in batch , To maximize the use of hardware . They can also be used cpu() and cuda() Method in CPU and GPU Transferred between .
smiles_list = ["CCSCCSP(=S)(OC)OC", "CCOC(=O)N",
"N(Nc1ccccc1)c2ccccc2", "NC(=O)c1cccnc1"]
mols = data.PackedMolecule.from_smiles(smiles_list)
mols.visualize()
mols = mols.cuda()
print(mols)

It's like the original PyTorch Tensors are the same , Graph supports a wide range of indexing operations . Typical uses include application node masking 、 Edge shielding or graphic shielding . The following example shows how to select an edge that contains at least one carbon . See notes for more graphic operations .
node_in, node_out, bond_type = mols.edge_list.t()
edge_mask = (mols.atom_type[node_in] == td.CARBON) | \
(mols.atom_type[node_out] == td.CARBON)
mols = mols.edge_mask(edge_mask)
mols.visualize()

边栏推荐
- 蓝桥:合根植物
- 力扣刷题日记/day7/6.30
- Crawler (6) - Web page data parsing (2) | the use of beautifulsoup4 in Crawlers
- "In Vietnam, money is like lying on the street"
- With an estimated value of 90billion, the IPO of super chip is coming
- Scala基础教程--13--函数进阶
- 力扣刷题日记/day2/2022.6.24
- 【2022年江西省研究生数学建模】冰壶运动 思路分析及代码实现
- [HCIA continuous update] WAN technology
- [HCIA continuous update] network management and operation and maintenance
猜你喜欢

删除二叉搜索树中的节点附图详解

爬虫初级学习

中国农科院基因组所汪鸿儒课题组诚邀加入

Installation and use of VMware Tools and open VM tools: solve the problems of incomplete screen and unable to transfer files of virtual machines

能源行业的数字化“新”运维

Li Kou brush question diary /day5/2022.6.27

I wrote a learning and practice tutorial for beginners!

2022年全国CMMI认证补贴政策|昌旭咨询

2022 national CMMI certification subsidy policy | Changxu consulting

Scala基础教程--13--函数进阶
随机推荐
MySQL常用增删改查操作(CRUD)
Lua emmylua annotation details
[2022 Jiangxi graduate mathematical modeling] curling movement idea analysis and code implementation
General environmental instructions for the project
78 year old professor Huake impacts the IPO, and Fengnian capital is expected to reap dozens of times the return
Interview summary of large factory Daquan II
【系统盘转回U盘】记录系统盘转回U盘的操作
Android uses sqliteopenhelper to flash back
完善的js事件委托
Journal des problèmes de brosse à boutons de force / day6 / 6.28
Blue bridge: sympodial plant
With the stock price plummeting and the market value shrinking, Naixue launched a virtual stock, which was deeply in dispute
2022年全国CMMI认证补贴政策|昌旭咨询
How is the entered query SQL statement executed?
The controversial line of energy replenishment: will fast charging lead to reunification?
Microservice architecture debate between radical technologists vs Project conservatives
【Go语言刷题篇】Go完结篇|函数、结构体、接口、错误入门学习
"In Vietnam, money is like lying on the street"
Scala基础教程--12--读写数据
Principle and application of ThreadLocal