Commit ba9d30bc authored by Bharath Ramsundar's avatar Bharath Ramsundar
Browse files

Merge branch 'master' of https://github.com/deepchem/deepchem into website

parents d63bf9b5 3a03e958
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ import warnings
from deepchem.models import Model
from deepchem.models.autoencoder_models.model import MoleculeVAE
from deepchem.feat.one_hot import zinc_charset
from deepchem.utils import download_url
import os
from subprocess import call

@@ -64,8 +65,8 @@ class TensorflowMoleculeEncoder(Model):
    weights_file = os.path.join(current_dir, weights_filename)

    if not os.path.exists(weights_file):
      wget_command = "wget -nv -c http://karlleswing.com/misc/keras-molecule/model.h5"
      call(wget_command.split())
      download_url("http://karlleswing.com/misc/keras-molecule/model.h5",
                   current_dir)
      mv_cmd = "mv model.h5 %s" % weights_file
      call(mv_cmd.split())
    return TensorflowMoleculeEncoder(
@@ -136,8 +137,8 @@ class TensorflowMoleculeDecoder(Model):
    weights_file = os.path.join(current_dir, weights_filename)

    if not os.path.exists(weights_file):
      wget_command = "wget -nv -c http://karlleswing.com/misc/keras-molecule/model.h5"
      call(wget_command.split())
      download_url("http://karlleswing.com/misc/keras-molecule/model.h5",
                   current_dir)
      mv_cmd = "mv model.h5 %s" % weights_file
      call(mv_cmd.split())
    return TensorflowMoleculeDecoder(
+17 −1
Original line number Diff line number Diff line
@@ -422,11 +422,27 @@ class AtomicDifferentiatedDense(Layer):
    in_channels = inputs.get_shape().as_list()[-1]
    self.W = self.init(
        [len(self.atom_number_cases), in_channels, self.out_channels])

    self.b = model_ops.zeros((len(self.atom_number_cases), self.out_channels))
    outputs = []
    for i, atom_case in enumerate(self.atom_number_cases):

      # optimization to allow for tensorcontraction/broadcasted mmul
      # using a reshape trick. Note that the np and tf matmul behavior
      # differs when dealing with broadcasts

      a = inputs  # (i,j,k)
      b = self.W[i, :, :]  # (k, l)

      ai = tf.shape(a)[0]
      aj = tf.shape(a)[1]
      ak = tf.shape(a)[2]
      bl = tf.shape(b)[1]

      output = self.activation(
          tf.tensordot(inputs, self.W[i, :, :], [[2], [0]]) + self.b[i, :])
          tf.reshape(tf.matmul(tf.reshape(a, [ai * aj, ak]), b), [ai, aj, bl]) +
          self.b[i, :])

      mask = 1 - tf.to_float(tf.cast(atom_numbers - atom_case, tf.bool))
      output = tf.reshape(output * tf.expand_dims(mask, 2), (-1, self.max_atoms,
                                                             self.out_channels))
+8 −16
Original line number Diff line number Diff line
@@ -14,18 +14,14 @@ def load_bace_regression(featurizer='ECFP', split='random', reload=True):
  """Load bace datasets."""
  # Featurize bace dataset
  print("About to featurize bace dataset.")
  if "DEEPCHEM_DATA_DIR" in os.environ:
    data_dir = os.environ["DEEPCHEM_DATA_DIR"]
  else:
    data_dir = "/tmp"
  data_dir = deepchem.utils.get_data_dir()
  if reload:
    save_dir = os.path.join(data_dir, "bace_r/" + featurizer + "/" + split)

  dataset_file = os.path.join(data_dir, "bace.csv")

  if not os.path.exists(dataset_file):
    os.system(
        'wget -P ' + data_dir +
    deepchem.utils.download_url(
        'http://deepchem.io.s3-website-us-west-1.amazonaws.com/datasets/bace.csv'
    )

@@ -80,18 +76,14 @@ def load_bace_classification(featurizer='ECFP', split='random', reload=True):
  """Load bace datasets."""
  # Featurize bace dataset
  print("About to featurize bace dataset.")
  if "DEEPCHEM_DATA_DIR" in os.environ:
    data_dir = os.environ["DEEPCHEM_DATA_DIR"]
  else:
    data_dir = "/tmp"
  data_dir = deepchem.utils.get_data_dir()
  if reload:
    save_dir = os.path.join(data_dir, "bace_c/" + featurizer + "/" + split)

  dataset_file = os.path.join(data_dir, "bace.csv")

  if not os.path.exists(dataset_file):
    os.system(
        'wget -P ' + data_dir +
    deepchem.utils.download_url(
        'http://deepchem.io.s3-website-us-west-1.amazonaws.com/datasets/bace.csv'
    )

+3 −7
Original line number Diff line number Diff line
@@ -13,17 +13,13 @@ def load_bbbp(featurizer='ECFP', split='random', reload=True):
  """Load blood-brain barrier penetration datasets """
  # Featurize bbb dataset
  print("About to featurize bbbp dataset.")
  if "DEEPCHEM_DATA_DIR" in os.environ:
    data_dir = os.environ["DEEPCHEM_DATA_DIR"]
  else:
    data_dir = "/tmp"
  data_dir = deepchem.utils.get_data_dir()
  if reload:
    save_dir = os.path.join(data_dir, "bbbp/" + featurizer + "/" + split)

  dataset_file = os.path.join(data_dir, "BBBP.csv")
  if not os.path.exists(dataset_file):
    os.system(
        'wget -P ' + data_dir +
    deepchem.utils.download_url(
        'http://deepchem.io.s3-website-us-west-1.amazonaws.com/datasets/BBBP.csv'
    )

+17 −28
Original line number Diff line number Diff line
@@ -16,45 +16,34 @@ def load_chembl(shard_size=2000,
                split="random",
                reload=True):

  if "DEEPCHEM_DATA_DIR" in os.environ:
    data_dir = os.environ["DEEPCHEM_DATA_DIR"]
  else:
    data_dir = "/tmp"
  data_dir = deepchem.utils.get_data_dir()
  if reload:
    save_dir = os.path.join(data_dir, "chembl/" + featurizer + "/" + split)

  dataset_path = os.path.join(data_dir, "chembl_%s.csv.gz" % set)
  if not os.path.exists(dataset_path):
    os.system(
        'wget -P ' + data_dir +
    deepchem.utils.download_url(
        'http://deepchem.io.s3-website-us-west-1.amazonaws.com/datasets/chembl_5thresh.csv.gz'
    )
    os.system(
        'wget -P ' + data_dir +
    deepchem.utils.download_url(
        'http://deepchem.io.s3-website-us-west-1.amazonaws.com/datasets/chembl_sparse.csv.gz'
    )
    os.system(
        'wget -P ' + os.path.join(data_dir, 'chembl_year_sets') +
    deepchem.utils.download_url(
        'http://deepchem.io.s3-website-us-west-1.amazonaws.com/datasets/chembl_year_sets/chembl_5thresh_ts_test.csv.gz'
    )
    os.system(
        'wget -P ' + os.path.join(data_dir, 'chembl_year_sets') +
    deepchem.utils.download_url(
        'http://deepchem.io.s3-website-us-west-1.amazonaws.com/datasets/chembl_year_sets/chembl_5thresh_ts_train.csv.gz'
    )
    os.system(
        'wget -P ' + os.path.join(data_dir, 'chembl_year_sets') +
    deepchem.utils.download_url(
        'http://deepchem.io.s3-website-us-west-1.amazonaws.com/datasets/chembl_year_sets/chembl_5thresh_ts_valid.csv.gz'
    )
    os.system(
        'wget -P ' + os.path.join(data_dir, 'chembl_year_sets') +
    deepchem.utils.download_url(
        'http://deepchem.io.s3-website-us-west-1.amazonaws.com/datasets/chembl_year_sets/chembl_sparse_ts_test.csv.gz'
    )
    os.system(
        'wget -P ' + os.path.join(data_dir, 'chembl_year_sets') +
    deepchem.utils.download_url(
        'http://deepchem.io.s3-website-us-west-1.amazonaws.com/datasets/chembl_year_sets/chembl_sparse_ts_train.csv.gz'
    )
    os.system(
        'wget -P ' + os.path.join(data_dir, 'chembl_year_sets') +
    deepchem.utils.download_url(
        'http://deepchem.io.s3-website-us-west-1.amazonaws.com/datasets/chembl_year_sets/chembl_sparse_ts_valid.csv.gz'
    )

Loading