Commit 06a1d604 authored by Bharath Ramsundar's avatar Bharath Ramsundar
Browse files

Partial fixes for python3 failures

parent f8a1e468
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -13,13 +13,13 @@ def one_of_k_encoding(x, allowable_set):
  if x not in allowable_set:
    raise Exception(
        "input {0} not in allowable set{1}:".format(x, allowable_set))
  return map(lambda s: x == s, allowable_set)
  return list(map(lambda s: x == s, allowable_set))

def one_of_k_encoding_unk(x, allowable_set):
  """Maps inputs not in the allowable set to the last element."""
  if x not in allowable_set:
    x = allowable_set[-1]
  return map(lambda s: x == s, allowable_set)
  return list(map(lambda s: x == s, allowable_set))

def get_intervals(l):
  """For list of lists, gets the cumulative products of the lengths"""
+1 −1
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ class ConvMol(object):
    self.deg_block_indices = np.array(deg_block_indices)

  def get_atoms_with_deg(self, deg):
    # Retrieves atom_features with the specific degree
    """Retrieves atom_features with the specific degree"""
    start_ind = self.deg_slice[deg-self.min_deg,0]
    size = self.deg_slice[deg-self.min_deg,1]
    return self.atom_features[start_ind:(start_ind+size),:]
+3 −3
Original line number Diff line number Diff line
@@ -90,8 +90,8 @@ def graph_conv(atoms, deg_adj_lists, deg_slice, max_deg, min_deg, W_list,
    self_atoms = tf.slice(atoms, begin, size)
    
    # Apply hidden affine to relevant atoms and append
    rel_out = affine(rel_atoms, W.next(), b.next())
    self_out = affine(self_atoms, W.next(), b.next())
    rel_out = affine(rel_atoms, next(W), next(b))
    self_out = affine(self_atoms, next(W), next(b))
    out = rel_out + self_out
    
    new_rel_atoms_collection[deg-min_deg] = out
@@ -105,7 +105,7 @@ def graph_conv(atoms, deg_adj_lists, deg_slice, max_deg, min_deg, W_list,
    self_atoms = tf.slice(atoms, begin, size)

    # Only use the self layer
    out = affine(self_atoms, W.next(), b.next())
    out = affine(self_atoms, next(W), next(b))
    
    new_rel_atoms_collection[deg-min_deg] = out        
      
+28 −22
Original line number Diff line number Diff line
@@ -10,6 +10,8 @@ __copyright__ = "Copyright 2016, Stanford University"
__license__ = "GPL"

import unittest
import tensorflow as tf
from keras import backend as K
from tensorflow.python.framework import test_util
from keras.layers import Dense, BatchNormalization
from deepchem.models.tf_keras_models.graph_models import SequentialGraphModel
@@ -55,7 +57,11 @@ class TestGraphModels(test_util.TensorFlowTestCase):
    assert len(graph_model.layers) == 6

  def test_sample_attn_lstm_architecture(self):
    """Tests that a representative attention architecture can be created."""
    """Tests that an attention architecture can be created without crash."""
    g = tf.Graph()
    sess = tf.Session(graph=g)
    K.set_session(sess)
    with g.as_default():
      max_depth = 5
      n_test = 5
      n_support = 11