xnuohz / dimenet-dgl Goto Github PK
View Code? Open in Web Editor NEWA DGL implementation of "Directional Message Passing for Molecular Graphs" (ICLR 2020).
A DGL implementation of "Directional Message Passing for Molecular Graphs" (ICLR 2020).
I converted pre-trained tf weights to torch format, and got inconsistent tensor between tf.math.unsorted_segment_sum and g.update_all. Here is a simple example to simulate above process, but it got the same result.
import dgl
import torch
import dgl.function as fn
import tensorflow as tf
import numpy as np
# torch
dst = torch.tensor([ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11,
11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14,
14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15])
src = torch.tensor([ 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 0, 2, 3, 4, 5, 7,
8, 9, 10, 11, 12, 13, 0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 15, 0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0,
1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3,
4, 6, 7, 8, 9, 12, 13, 14, 15, 2, 3, 4, 5, 7, 8, 9, 12, 13,
14, 15, 0, 1, 2, 3, 4, 5, 6, 8, 9, 12, 13, 14, 15, 0, 1, 2,
3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5,
6, 7, 8, 10, 11, 12, 13, 0, 1, 2, 3, 4, 8, 9, 11, 12, 0, 1,
2, 3, 4, 8, 9, 10, 12, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 14, 15, 3, 4, 5, 6,
7, 8, 13, 15, 2, 3, 4, 5, 6, 7, 8, 12, 13, 14])
g = dgl.graph((src, dst))
g.edata['tmp'] = torch.arange(g.num_edges()).unsqueeze(-1).float()
g.update_all(fn.copy_e('tmp', 'x'), fn.sum('x', 't'))
n_atoms = g.num_nodes()
idnb_i = tf.constant([ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11,
11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14,
14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15])
x = tf.constant(np.arange(g.num_edges()).reshape([-1, 1]))
x = tf.math.unsorted_segment_sum(x, idnb_i, n_atoms)
print(g.ndata['t'])
print(x)
Could you take a look? @mufeili
The units in the performance table are not consistent. For example, 0.0246
should be 24.6
?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.