Code Monkey home page Code Monkey logo

dimenet-dgl's People

Contributors

xnuohz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dimenet-dgl's Issues

Inconsistent in tf and torch api

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.