문서 | 튜토리얼 | 벤치 마크 | 논문이 구현되었습니다
Torchdrug는 여러 목적으로 설계된 Pytorch 기반 머신 러닝 도구 상자입니다.
Torchdrug는 Linux, Windows 또는 MacOS에 설치할 수 있습니다. 3.7 <= Python <= 3.10 및 Pytorch> = 1.8.0과 호환됩니다.
conda install torchdrug -c milagraph -c conda-forge -c pytorch -c pygpip install torch==1.9.0
pip install torch-scatter torch-cluster -f https://pytorch-geometric.com/whl/torch-1.9.0+cu102.html
pip install torchdrug 다른 Pytorch 또는 Cuda 버전의 torch-scatter 설치하려면 https://github.com/rusty1s/pytorch_scatter의 지침을 참조하십시오.
git clone https://github.com/DeepGraphLearning/torchdrug
cd torchdrug
pip install -r requirements.txt
python setup.py install먼저 Visual Studio 용 빌드 도구를 설치해야합니다. 그런 다음 PowerShell에 다음 모듈을 설치합니다.
Install-Module Pscx - AllowClobber
Install-Module VSSetup다음 명령으로 PowerShell에서 Visual Studio를 초기화하십시오. PowerShell 프로파일에 작성하여 모든 PowerShell 세션에 대해 이것을 설정할 수 있습니다. 자신의 경우에 따라 라이브러리 경로를 변경하십시오.
Import-VisualStudioVars - Architecture x64
$ env: LIB += " ;C:Program FilesPython37libs " Apple Silicon에서 Torchdrug를 실행하려면 Pytorch> = 1.13이 필요합니다. torch-scatter 및 torch-cluster 의 경우 소스에서 컴파일 할 수 있습니다. 참고 Torchdrug는 mps 장치를 지원하지 않습니다.
pip install torch==1.13.0
pip install git+https://github.com/rusty1s/pytorch_scatter.git
pip install git+https://github.com/rusty1s/pytorch_cluster.git
pip install torchdrugTorchdrug는 인간을 위해 설계되었으며 그래프 구조화 된 데이터에 중점을 둡니다. 기계 학습 모델에서 그래프 작업을 쉽게 구현할 수 있습니다. Torchdrug의 모든 작업은 Pytorch 프레임 워크에 의해 뒷받침되며 GPU 가속 및 자동 차별화를 지원합니다.
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 = graph . cuda ()
# the subgraph induced by nodes 2, 3 & 4
subgraph = graph . subgraph ([ 2 , 3 , 4 ])분자는 또한 Torchdrug에서지지됩니다. 도메인 지식없이 원하는 분자 특성을 얻을 수 있습니다.
mol = data . Molecule . from_smiles ( "CCOC(=O)N" , atom_feature = "default" , bond_feature = "default" )
print ( mol . node_feature )
print ( mol . atom_type )
print ( mol . to_scaffold ())사용자 정의 노드, 에지 또는 그래프 속성을 등록 할 수도 있습니다. 인덱싱 작업 중에 자동으로 처리됩니다.
with mol . edge ():
mol . is_CC_bond = ( mol . edge_list [:, : 2 ] == td . CARBON ). all ( dim = - 1 )
sub_mol = mol . subgraph ( mol . atom_type != td . NITROGEN )
print ( sub_mol . is_CC_bond )Torchdrug는 광범위한 일반적인 데이터 세트와 약물 발견을위한 빌딩 블록을 제공합니다. 최소한의 코드를 사용하면 표준 모델을 적용하여 자신의 문제를 해결할 수 있습니다.
import torch
from torchdrug import datasets
dataset = datasets . Tox21 ()
dataset [ 0 ]. visualize ()
lengths = [ int ( 0.8 * len ( dataset )), int ( 0.1 * len ( dataset ))]
lengths += [ len ( dataset ) - sum ( lengths )]
train_set , valid_set , test_set = torch . utils . data . random_split ( dataset , lengths ) from torchdrug import models , tasks
model = models . GIN ( dataset . node_feature_dim , hidden_dims = [ 256 , 256 , 256 , 256 ])
task = tasks . PropertyPrediction ( model , task = dataset . tasks )훈련 및 추론은 다중 CPU 또는 GPU에 의해 가속화됩니다. 이것은 코드 라인만으로 Torchdrug에서 완벽하게 전환 할 수 있습니다.
from torchdrug import core
# Single CPU / Multiple CPUs / Distributed CPUs
solver = core . Engine ( task , train_set , valid_set , test_set , optimizer )
# Single GPU
solver = core . Engine ( task , train_set , valid_set , test_set , optimizer , gpus = [ 0 ])
# Multiple GPUs
solver = core . Engine ( task , train_set , valid_set , test_set , optimizer , gpus = [ 0 , 1 , 2 , 3 ])
# Distributed GPUs
solver = core . Engine ( task , train_set , valid_set , test_set , optimizer , gpus = [ 0 , 1 , 2 , 3 , 0 , 1 , 2 , 3 ])체중 및 바이어스 플랫폼을 통해 실험을 쉽게 추적하고 관리 할 수 있습니다.
solver = core . Engine ( task , train_set , valid_set , test_set , optimizer , logger = "wandb" )모든 사람들은 Torchdrug의 발전에 기여할 수 있습니다. 자세한 내용은 기고 가이드 라인을 참조하십시오.
Torchdrug는 Apache-2.0 라이센스에 따라 릴리스됩니다.