Commit 74414af3 authored by Yutong Zhao's avatar Yutong Zhao
Browse files

yapf and cleanup

parent be07198b
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -3287,20 +3287,14 @@ class ANIFeat(Layer):
    # d = tf.nn.relu(d) # fix numerical instabilities about diagonal
    # d = tf.sqrt(d) # does this have negative elements? may be unstable for diagonals

    # d = d * flags

    max_atoms = self.max_atoms
    tensor1 = tf.stack([coordinates] * max_atoms, axis=1)
    tensor2 = tf.stack([coordinates] * max_atoms, axis=2)

    # Calculate pairwise distance
    # d = tf.sqrt(
        # tf.nn.relu(
            # tf.reduce_sum(tf.squared_difference(tensor1, tensor2), axis=3)))
    d = tf.sqrt(
        tf.reduce_sum(tf.squared_difference(tensor1, tensor2), axis=3) + 1e-7)
    # d = tf.reduce_sum(tf.squared_difference(tensor1, tensor2), axis=3)
    # Masking for valid atom index

    d = d * flags
    return d

+6 −9
Original line number Diff line number Diff line
@@ -15,20 +15,17 @@ class TestANIRegression(unittest.TestCase):

    max_atoms = 4

    X = np.array([
      [
    X = np.array([[
        [1, 5.0, 3.2, 1.1],
        [6, 1.0, 3.4, -1.1],
        [1, 2.3, 3.4, 2.2],
        [0, 0, 0, 0],
      ],
      [
    ], [
        [8, 2.0, -1.4, -1.1],
        [7, 6.3, 2.4, 3.2],
        [0, 0, 0, 0],
        [0, 0, 0, 0],
      ]
      ])
    ]])

    y = np.array([2.0, 1.1])