Recent Releases of torchdrug
torchdrug - 0.2.1 Release
The new 0.2.1 release supports PyTorch 2.0 and Python 3.10. We fix quite a few bugs based on the suggestions from the community. Thanks everyone for contributing to this library.
Compatibility Changes
- TorchDrug now supports Python versions from 3.7 to 3.10, and PyTorch versions from 1.8 to 2.0. There is no change in the minimal versions, so you can easily update your previous environment to use TorchDrug 0.2.1.
- For
PropertyPrediction, we change the itspredictfunction to directly output original values rather than standardized values. This is more intuitive for new users. Note this change is not backward compatible. (#109, thanks to @kanojikajino)
Improvements
- Add batch normalization and dropout in
PropertyPrediction - Support custom edge feature function in
GraphConstruction - Support ESM-2 models in
EvolutionaryScaleModeling - Add full batch evaluation for
KnowledgeGraphCompletion - Support dict, list and tuple in config dict
- Add instructions for installation on Apple silicon (#176, thanks to @migalkin)
- Reduce dependency to
matplotlib-base(#141, thanks to @jamesmyatt)
Bug Fixes
- Fix variable names in
NeuralLogicProgramming(#126) - Fix interface for the new esm library (#133)
- Fix the version of
AlphaFoldDBtov2(#137, thanks to @ShoufaChen) - Fix inconsistent output when using edge features in convolution layers (#53, #140)
- Handle side cases in property optimization (#125, thanks to @jannisborn)
- Fix a bug when using LR schedulers (#148, #152)
- Fix a bug in graph construction (#158)
- Fix a bug in
layers.Set2Set(#185) - Avoid in-place RDKit operations in
data.Molecule.from_molecule(#142) - Fix
num_classin PropertyPrediction (#142) - Fix docker file for new CUDA image (#207, thanks to @cscandore)
- Fix chain ID in
data.Protein.from_molecule
Deprecations
- Deprecate
functional._size_to_index. Usetorch.repeat_interleaveinstead.
- Python
Published by KiddoZhu almost 3 years ago
torchdrug - 0.2.0 Release
V0.2.0 is a major release with a new family member TorchProtein, a library for machine-learning-guided protein science. Aiming at simplifying the development of protein methods, TorchProtein encapsulates many complicated yet repetitive subroutines into functional modules, including widely-used datasets, flexible data processing operations, advanced encoding models, and diverse protein tasks.
Such comprehensive encapsulation enables users to develop protein machine learning solutions with one easy-to-use library. It avoids the embarrassment of gluing multiple libraries into a pipeline.
With TorchProtein, we can rapidly prototype machine learning solutions to various protein applications within 20 lines of codes, and conduct ablation studies by substituting different parts of the solution with off-the-shelf modules. Furthermore, we can easily adapt these modules to our own needs, and make systematic analyses by comparing the new results to a benchmark provided in the library.
Additionally, TorchProtein is designed to be accessible to everyone. For inexperienced users, like beginners or biological researchers, TorchProtein provides user-friendly APIs to simplify the development of protein machine learning solutions. Meanwhile, for professional users, TorchProtein also preserves enough flexibility to satisfy their demands, supported by features like modular design of the library and on-the-fly graph construction.
Main Features
Simplify Data Processing
It is challenging to transform raw bioinformatic protein datasets into tensor formats for machine learning. To reduce tedious operations, TorchProtein provides us with a data structure
data.Proteinand its batched extensiondata.PackedProteinto automate the data processing step.data.Proteinanddata.PackedProteinautomatically gather protein data from various bio-sources and seamlessly switch between data formats like pdb files, RDKit objects and sequences. Please see the section data structures and operations for transforming from and to sequences and RDKit objects.```python
construct a data.Protein instance from a pdb file
pdbfile = ... protein = data.Protein.frompdb(pdbfile, atomfeature="position", bondfeature="length", residuefeature="symbol") print(protein)
write a data.Protein instance back to a pdb file
newpdbfile = ... protein.topdb(newpdb_file) ```
bash Protein(num_atom=445, num_bond=916, num_residue=57)data.Proteinanddata.PackedProteinautomatically pre-process all kinds of features of atoms, bonds and residues, by simply setting up several arguments.```python pdbfile = ... protein = data.Protein.frompdb(pdbfile, atomfeature="position", bondfeature="length", residuefeature="symbol")
feature
print(protein.residuefeature.shape) print(protein.atomfeature.shape) print(protein.bond_feature.shape) ```
bash torch.Size([57, 21]) torch.Size([445, 3]) torch.Size([916, 1])data.Proteinanddata.PackedProteinautomatically keeps track of numerous attributes associated with atoms, bonds, residues and the whole protein.- For example, reference offers a way to register new attributes as node, edge or graph property, and in this way, the new attributes would automatically go along with the node, edge or graph themself. More in-built attributes are listed in the section data structures and operations.
```python protein = ...
with protein.node(): protein.nodeid = torch.tensor([i for i in range(0, protein.numnode)]) with protein.edge(): protein.edgecost = torch.rand(protein.numedge) with protein.graph(): protein.graph_feature = torch.randn(128) ``
- Even more, reference can be utilized to maintain the correspondence between two well related objects. For example, the mappingatom2residue` maintains relationship between atoms and residues, and enables indexing on either of them.```python protein = ...
create a mask indices for atoms in a glutamine (GLN)
isglutamine = protein.residuetype[protein.atom2residue] == protein.residue2id["GLN"] maskindices = isglutamine.nonzero().squeeze(-1) print(mask_indices)
map the masked atoms back to the glutamine residue
residuetype = protein.residuetype[protein.atom2residue[maskindices]] print([protein.id2residue[r] for r in residuetype.tolist()]) ```
bash tensor([ 26, 27, 28, 29, 30, 31, 32, 33, 34, 307, 308, 309, 310, 311, 312, 313, 314, 315, 384, 385, 386, 387, 388, 389, 390, 391, 392]) ['GLN', 'GLN', 'GLN', 'GLN', 'GLN', 'GLN', 'GLN', 'GLN', 'GLN', 'GLN', 'GLN', 'GLN', 'GLN', 'GLN', 'GLN', 'GLN', 'GLN', 'GLN', 'GLN', 'GLN', 'GLN', 'GLN', 'GLN', 'GLN', 'GLN', 'GLN', 'GLN']
It is useful to augment protein data by modifying protein graphs or constructing new ones. With the protein operations and the graph construction layers provided in TorchProtein,
we can easily modify proteins on the fly by batching, slicing sequences, masking out side chains, etc. Please see the tutorials for more details on masking.
```python pdbfile = ... protein = data.Protein.frompdb(pdbfile, atomfeature="position", bondfeature="length", residuefeature="symbol")
batch
proteins = data.Protein.pack([protein, protein, protein])
slice sequences
use indexing to extract consecutive residues of a particular protein
tworesidues = protein[[0,2]] tworesidues.visualize() ```

we can construct protein graphs on the fly with GPU acceleration, which offers users flexible choices rather than using fixed pre-processed graphs. Below is an example to build a graph with only alpha carbon atoms, please check tutorials for more cases, such as adding spatial / KNN / sequential edges.
```python protein = ...
transfer from CPU to GPU
protein = protein.cuda() print(protein)
build a graph with only alpha carbon (CA) atoms
nodelayers = [geometry.AlphaCarbonNode()] graphconstructionmodel = layers.GraphConstruction(nodelayers=node_layers)
originalprotein = data.Protein.pack([protein]) CAprotein = graphconstructionmodel(protein) print("Graph before:", originalprotein) print("Graph after:", CA_protein) ```
bash Protein(num_atom=445, num_bond=916, num_residue=57, device='cuda:0') Graph before: PackedProtein(batch_size=1, num_atoms=[2639], num_bonds=[5368], num_residues=[350]) Graph after: PackedProtein(batch_size=1, num_atoms=[350], num_bonds=[0], num_residues=[350])
Easy to Prototype Solutions
With TorchProtein, common protein tasks can be finished within 20 lines of codes, such as sequence-based protein property prediction task. Below is an example and more examples of different popular protein tasks and models can be found in Protein Tasks, Models and Tutorials.
```python import torch from torchdrug import datasets, transforms, models, tasks, core
truncatetransform = transforms.TruncateProtein(maxlength=200, random=False) proteinviewtransform = transforms.ProteinView(view="residue") transform = transforms.Compose([truncatetransform, proteinview_transform])
dataset = datasets.BetaLactamase("~/protein-datasets/", residueonly=True, transform=transform) trainset, validset, testset = dataset.split()
model = models.ProteinCNN(inputdim=21, hiddendims=[1024, 1024], kernel_size=5, padding=2, readout="max")
task = tasks.PropertyPrediction(model, task=dataset.tasks, criterion="mse", metric=("mae", "rmse", "spearmanr"), normalization=False, nummlplayer=2)
optimizer = torch.optim.Adam(task.parameters(), lr=1e-4) solver = core.Engine(task, trainset, validset, testset, optimizer, gpus=[0], batchsize=64) solver.train(num_epoch=10) solver.evaluate("valid") ```
bash
mean absolute error [scaled_effect1]: 0.249482
root mean squared error [scaled_effect1]: 0.304326
spearmanr [scaled_effect1]: 0.44572
Compatible with Existing Molecular Models in TorchDrug
TorchProtein follows the scientific fact that proteins are macromolecules. The core data structures
data.Proteinanddata.PackedProteininherit fromdata.Moleculeanddata.PackedMoleculerespectively. Therefore, we can apply any existing molecule model in TorchDrug to proteins```python import torch from torchdrug import layers, datasets, transforms, models, tasks, core from torchdrug.layers import geometry
truncatetransform = transforms.TruncateProtein(maxlength=200, random=False) proteinviewtransform = transforms.ProteinView(view="residue") transform = transforms.Compose([truncatetransform, proteinview_transform])
dataset = datasets.EnzymeCommission("~/protein-datasets/", transform=transform) trainset, validset, test_set = dataset.split()
model = models.GIN(inputdim=21, hiddendims=[256, 256, 256, 256], batchnorm=True, shortcut=True, concat_hidden=True)
graphconstructionmodel = layers.GraphConstruction( nodelayers=[geometry.AlphaCarbonNode()], edgelayers=[geometry.SpatialEdge(radius=10.0, mindistance=5), geometry.KNNEdge(k=10, mindistance=5), geometry.SequentialEdge(maxdistance=2)], edgefeature="residue_type" )
task = tasks.MultipleBinaryClassification(model, graphconstructionmodel=graphconstructionmodel, nummlplayer=3, task=list(range(len(dataset.tasks))), criterion="bce", metric=("auprc@micro", "f1_max"))
optimizer = torch.optim.Adam(task.parameters(), lr=1e-4) solver = core.Engine(task, trainset, validset, testset, optimizer, gpus=[0], batchsize=4) solver.train(num_epoch=10) solver.evaluate("valid") ```
bash auprc@micro: 0.187884 f1_max: 0.231008In Protein-Ligand Interaction (PLI) prediction task, we can utilize a molecular encoder module to extract the representations of molecules. Please check tutorial 2 for more details.
```python trainset, validset, test_set = ...
protein encoder
model = models.ProteinCNN(inputdim=21, hiddendims=[1024, 1024], kernel_size=5, padding=2, readout="max")
molecule encoder
model2 = models.GIN(inputdim=66, hiddendims=[256, 256, 256, 256], batchnorm=True, shortcut=True, concat_hidden=True)
task = tasks.InteractionPrediction(model, model2=model2, task=dataset.tasks, criterion="mse", metric=("mae", "rmse", "spearmanr"), normalization=False, nummlplayer=2)
optimizer = torch.optim.Adam(task.parameters(), lr=1e-4) solver = core.Engine(task, trainset, validset, testset, optimizer, gpus=[0], batchsize=16) solver.train(num_epoch=5) solver.evaluate("valid") ```
bash mean absolute error [scaled_effect1]: 0.249482 root mean squared error [scaled_effect1]: 0.304326 spearmanr [scaled_effect1]: 0.44572
Support From the Developer (@DeepGraphLearning/torchdrug-maintainers)
There is always an active supporting team to answer questions and provide helps. Feedbacks of use experience and contributions for development are welcomed.
New Modules
Data Structures and Operations
data.Protein
- Representative attributes:
data.Protein.edge_list: list of edges and each edge is represented by a tuple (nodein, nodeout, bond_type)data.Protein.atom_type: atom typesdata.Protein.bond_type: bond typesdata.Protein.residue_type: residue typesdata.Protein.view: default view for this protein. Can be “atom” or “residue”data.Protein.atom_name: atom names in each residuedata.Protein.atom2residue: atom id to residue id mappingdata.Protein.is_hetero_atom: hetero atom indicatordata.Protein.occupancy: protein occupancydata.Protein.b_factor: temperature factorsdata.Protein.residue_number: residue numbersdata.Protein.insertion_code: insertion codesdata.Protein.chain_id: chain ids
- Representative Methods:
data.Protein.from_molecule: create a protein from an RDKit object.data.Protein.from_sequence: create a protein from a sequence.data.Protein.from_sequence_fast: a faster version of creating a protein from a sequence.data.Protein.from_pdb: create a protein from a PDB file.data.Protein.to_molecule: return an RDKit object of this protein.data.Protein.to_sequence: return a sequence of this protein.data.Protein.to_pdb: write this protein to a pdb file.data.Protein.split: split this protein graph into multiple disconnected protein graphs.data.Protein.pack: batch a list ofdata.Proteinintodata.PackedProtein.data.Protein.repeat: repeat this protein.data.Protein.residue2atom: map residue id to atom ids.data.Protein.residue_mask: return a masked protein based on the specified residues.data.Protein.subresidue: return a subgraph based on the specified residues.data.Protein.residue2graph: residue id to protein id mapping.data.Protein.node_mask: return a masked protein based on the specified nodes.data.Protein.edge_mask: return a masked protein based on the specified edges.data.Protein.compact: remove isolated nodes and compact node ids.
data.PackedProtein
- Representative attributes:
data.PackedProtein.edge_list: list of edges and each edge is represented by a tuple (nodein, nodeout, bond_type)data.PackedProtein.atom_type: atom typesdata.PackedProtein.bond_type: bond typesdata.PackedProtein.residue_type: residue typesdata.PackedProtein.view: default view for this protein. Can be “atom” or “residue”data.PackedProtein.num_nodes: number of nodes in each protein graphdata.PackedProtein.num_edges: number of edges in each protein graphdata.PackedProtein.num_residues: number of residues in each protein graphdata.PackedProtein.offsets: node id offsets in different proteins
- Representative methods:
data.PackedProtein.node_mask: return a masked packed protein based on the specified nodes.data.PackedProtein.edge_mask: return a masked packed protein based on the specified edges.data.PackedProtein.residue_mask: return a masked packed protein based on the specified residues.data.PackedProtein.graph_mask: return a masked packed protein based on the specified protein graphs.data.PackedProtein.from_molecule: create a protein from a list of RDKit objects.data.PackedProtein.from_sequence: create a protein from a list of sequences.data.PackedProtein.from_sequence_fast: a faster version of creating a protein from a list of sequences.data.PackedProtein.from_pdb: create a protein from a list of PDB files.data.PackedProtein.to_molecule: return a list of RDKit objects of this packed protein.data.PackedProtein.to_sequence: return a list of sequences of this packed protein.data.PackedProtein.to_pdb: write this packed protein to a list of pdb files.data.PackedProtein.merge: merge multiple packed proteins into a single packed protein.data.PackedProtein.repeat: repeat this packed protein.data.PackedProtein.repeat_interleave: repeat this packed protein, behaving similarly totorch.repeat_interleave_.data.PackedProtein.residue2graph: residue id to graph id mapping.
Models
GearNet: Geometry Aware Relational Graph Neural Network.ESM: Evolutionary Scale Modeling (ESM).ProteinCNN: protein shallow CNN.ProteinResNet: protein ResNet.ProteinLSTM: protein LSTM.ProteinBERT: protein BERT.Statistic: the statistic feature engineering for protein sequence.Physicochemical: the physicochemical feature engineering for protein sequence.
Protein Tasks
Sequence-based Protein Property Prediction:
tasks.PropertyPredictionpredicts some property of each protein, such as Beta-lactamase activity, stability and solubility for proteins.tasks.NodePropertyPredictionpredicts some property of each residue in proteins, such as the secondary structure (coil, strand or helix) of each residue.tasks.ContactPredictionpredicts whether any pair of residues contact or not in the folded structure.tasks.InteractionPredictionpredicts the binding affinity of two interacting proteins or of a protein and a ligand, i.e. performing PPI affinity prediction or PLI affinity prediction.
Structure-based Protein Property Prediction:
tasks.MultipleBinaryClassificationpredicts whether a protein owns several specific functions or not with binary labels.
Pre-trained Protein Structure Representations:
- Self-Supervised Protein Structure Pre-training: acquires informative protein representations from massive unlabeled protein structures, such as
tasks.EdgePrediction,tasks.AttributeMasking,tasks.ContextPrediction,tasks.DistancePrediction,tasks.AnglePrediction,tasks.DihedralPrediction. - Fine-tuning on Downstream Task: fine-tunes the pre-trained protein encoder on downstream tasks, such as any property prediction task mentioned above.
Protein Datasets
Protein Property Prediction Datasets
BetaLactamase: protein sequences with activity labelsFluorescence: protein sequences with fitness labelsStability: protein sequences with stability labelsSolubility: protein sequences with solubility labelsBinaryLocalization: protein sequences with membrane-bound or soluble labelsSubcellularLocalization: protein sequences with natural cell location labelsEnzymeCommission: protein sequences and 3D structures with EC number labels for catalysis in biochemical reactionsGeneOntology: protein sequences and 3D structures with GO term labels, including molecular function (MF), biological process (BP) and cellular component (CC)AlphaFoldDB: protein sequences and 3D structures predicted by AlphaFold
Protein Structure Prediction Datasets
Fold: protein sequences and 3D structures with fold labels determined by the global structural topologySecondaryStructure: protein sequences and 3D structures with secondary structure labels determined by the local structuresProteinNet: protein sequences and 3D structures for the contact prediction task
Protein-Protein Interaction Prediction Datasets
HumanPPI: protein sequences with binary interaction labels for human proteinsYeastPPI: protein sequences with binary interaction labels for yeast proteinsPPIAffinity: protein sequences with binding affinity values measured by $p{Kd}$
Protein Ligand Interaction Prediction Datasets
BindingDB: protein sequences and molecule graphs with binding affinity between pairs of protein and ligandPDBBind: protein sequences and molecule graphs with binding affinity between pairs of protein and ligand
Data Transform Modules
TruncateProtein: truncate over long protein sequences into a fixed lengthProteinView: convert proteins to a specific view
Graph Construction Layers
SubsequenceNode: take a protein subsequence of a specific lengthSubspaceNode: extract a subgraph by only keeping neighboring nodes in a spatial ball for each centered nodeRandomEdgeMask: mask out some edges randomly from the protein graph
Tutorials
To help users gain a comprehensive understanding of TorchProtein, we recommend some user-friendly tutorials for its basic usage and examples to various protein-related tasks. These tutorials may also serve as boilerplate codes for users to develop their own applications.
- Tutorial 1 - Protein Data Structure for basic usage of TorchProtein, like how to represent proteins and what operations are feasible.
- Tutorial 2 - Sequence-based Protein Property Prediction for 5 types of protein sequence understanding tasks provided in TorchProtein.
- Tutorial 3 - Structure-based Protein Property Prediction for property prediction tasks based on protein structure representations.
- Tutorial 4 - Pre-trained Protein Structure Representations for self-supervised pre-training of protein structure encoders and its fine-tuning on downstream tasks.
Bug Fixes
- Fix an error in the decorator
@utils.cached(#118) - Fix an index error in
data.Graph.split()(#115) - Fix setting attribute
node_feature,edge_featureandgraph_feature(#116) - Fix incorrect node feature shape for the synthon dataset
USPTO50k(#116) - Fix a compatible issue when adding node/edge/graph reference and changing node/edge to atom/bond (#116, #117)
- Python
Published by KiddoZhu almost 4 years ago
torchdrug - 0.1.3 Release
TorchDrug 0.1.3 release introduces new features like W&B intergration and index reference. It also provides new functions and metrics for common development need. Note 0.1.3 has some compatibility changes and be careful when you update your TorchDrug from an older version.
- W&B Integration
- Index Reference
- New Functions
- New Metrics
- Improvements
- Bug Fixes
- Compatibility Changes
W&B Integration
Tracking experiment progress is one of the most important demand from ML researchers and developers. For TorchDrug users, we provide a native integration of W&B platform. By adding only one argument in core.Engine, TorchDrug will automatically copy every hyperparameter and training log to your W&B database (thanks to @manangoel99).
python
solver = core.Engine(task, train_set, valid_set, test_set, optimizer, logger="wandb")
Now you can track your training and validation performance in your browser, and compare them across different experiments.

Index Reference
Maintaining node and edge attributes could be painful when one applies a lot of transformations to a graph. TorchDrug aims to eliminate such tedious steps by registering custom attributes. This update extends the capacity of custom attributes to index reference. That means, we allow attributes to refer to indexes of nodes, edges or graphs, and they will be automatically maintained in any graph operation.
To use index reference, simply add a context manager when we define the attributes.
python
with graph.edge(), graph.edge_reference():
graph.inv_edge_index = torch.tensor(inv_edge_index)
Foor more details on index reference, please take a look at our notes. Typical use cases include
- A pointer to the inverse edge of each edge.
- A pointer to the parent node of each node in a tree.
- A pointer to the incoming tree edge of each node in a DFS.
Let us know if you find more interesting usage of index reference!
New Functions
Message passing over line graphs is getting more and more popular in the recent years. This version provides data.Graph.line_graph to efficiently construct line graphs on GPUs. It supports both a single graph or a batch of graphs.
We are constantly focusing on better batching of irregular structures, and the variadic functions in TorchDrug are an efficient way to process batch of variadic-sized tensors without padding. This update introduces 3 new variadic functions.
variadic_meshgridgenerates a meshgrid from two variadic tensors. Useful for implementing pairwise operations.variadic_to_paddedconverts a variadic tensor to a padded tensor.padded_to_variadicconverts a padded tensor to a variadic tensor.
New Metrics
New metrics include accuracy, matthews_corrcoef, pearsonr, spearmanr. All the metrics are the same as their counterparts in scipy, but they are implemented in PyTorch and support auto differentiation.
Improvements
- Add
data.Graph.to(#70, thanks to @cthoyt) - Extend
tasks.SynthonCompletionfor arbitrary atom features (#62) - Speed up lazy data loading (#58, thanks to @wconnell)
- Speed up rspmm cuda kernels
- Add docker support
- Add more documentation for
data.Graphanddata.Molecule
Bug Fixes
- Fix computation of output dimension in several GNNs (#92, thanks to @kanojikajino)
- Fix
data.PackedGraph.__getitem__when the batch is empty (#83, thanks to @jannisborn) - Fix patched modules for PyTorch>=1.6.0 (#77)
- Fix
make_configurablefortorch.utils.data(#85) - Fix
multi_slice_mask,variadic_maxfor multi-dimensional input - Fix
variadic_topkfor input containing infinite values
Compatibility Changes
TorchDrug now supports Python 3.7/3.8/3.9. Starting from this version, TorchDrug requires a minimal PyTorch version of 1.8.0 and a minimal RDKit version of 2020.09.
Argument node_feature and edge_feature are renamed to atom_feature and bond_feature in data.Molecule.from_smiles and data.Molecule.from_molecule. The old interface is still supported with deprecated warnings.
- Python
Published by KiddoZhu about 4 years ago
torchdrug - 0.1.2 Release
0.1.2 Release Notes
The recent 0.1.2 release of TorchDrug is an update on Colab tutorials, data structures, functions, datasets and bug fixes. We are grateful to see growing interests and involvement from the community, especially on the retrosynthesis task. Welcome more in the future!
- Colab Tutorials
- New Data Structures
- New Functions
- New Datasets
- Bug Fixes
Colab Tutorials
To familiarize users with the logic and capacity of TorchDrug, we compile a full set of Colab tutorials, covering from basic usage to different drug discovery tasks. All the tutorials are fully interactive and may serve as boilerplate code for your own applications.
- Basic Usage and Pipeline shows the manipulation of data structures like
data.Graphanddata.Molecule, as well as the training and evaluation pipelines for property prediction models. - Pretrained Molecular Representations demonstrates the steps for self-supervised pretraining of a molecular representation model and finetuning it on downstream tasks.
- De novo Molecule Design illustrates the routine of training generative models for molecule generation and finetuning them with reinforcement learning for property optimization. Two popular models, GCPN and GraphAF, are covered in the tutorial.
- Retrosynthesis shows how to use the state-of-the-art model, G2Gs, to predict a set reactants for synthesizing a target molecule.
- Knowledge Graph Reasoning goes through the steps of training and evaluating models for knowledge graph completion, including both knowledge graph embeddings and neural inductive logic programming.
New Data Structures
- A new data structure
data.Dictionarythat stores key-value mapping of PyTorch tensors on either CPUs or GPUs. It enjoys O(n) memory consumption and O(1) query time, and supports parallelism over batch of queries. This API provides a great opportunity for implementing sparse lookup tables or set operations in a PyTorchic style. - A new method
data.Graph.matchto efficiently retrieve all edges of specific patterns on either CPUs or GPUs. It scales linearly w.r.t. the number of patterns plus the number of retrieved edges, regardless the size of the graph. Typical usage of this method includes querying the existence of edges, generating random walks or even extracting ego graphs.
New Functions
Batching irregular structures, such as graphs, sets or sequences with different sizes, is a common demand in drug discovery. Instead of clumsy padding-based implementation, TorchDrug provides a family of functions that efficiently manipulate batch of variadic-sized tensors without padding. The update contains the following new variadic functions.
variadic_arangereturns a 1-D tensor that contains integer intervals of variadic sizes.variadic_softmaxcomputes softmax over categories with variadic sizes.variadic_sortsorts elements in sets with variadic sizes.variadic_randpermreturns random permutations for sets with variadic sizes, where thei-th permutation contains integers from 0 tosize[i] - 1.variadic_sampledraws samples with replacement from sets with variadic sizes.
New Datasets
- PCQM4M: A large-scale molecule property prediction dataset, originally used in OGB-LSC (thanks to @OPAYA )
Bug Fixes
- Fix import of sascorer in plogp evaluation (#18, #31)
- Fix atoms with stereo bonds in retrosynthesis (#42, #43)
- Fix lazy construction for molecule datasets (#30, thanks to @DaShenZi721 )
- Fix ChEMBLFiltered dataset (#36)
- Fix ZINC2m dataset (#33)
- Fix USPTO50k dataset (#32)
- Fix bugs in core.Configurable (#26)
- Fix/improve documentation (#16, #28, #41)
- Fix installation on macOS (#29)
- Python
Published by KatarinaYuan over 4 years ago